"Serving as the White House Press Secretary over the past year and a half has been the honour and adventure of a lifetime," Leavitt said in a post on social media site X.
"Karoline will now be one of my top outside advisors, and an influential voice within the Republican Party, as we work to defy History, and conclusively win the Midterm Elections," Trump said in a post on Truth Social.
Leavitt joined Trump's 2024 campaign and served as transition spokeswoman before Trump selected her to be White House press secretary, becoming the youngest person to be appointed to the role.
The 28-year-old recently returned to work after taking leave following the birth of her second child, a daughter, in May.
She also has a two-year-old son.
"The truth is since returning to the White House after the birth of my daughter, I have felt in my heart that I cannot be the best mom my two young children deserve while devoting the constant time, energy and attention required of the White House Press Secretary - and that is why I have ultimately made the bittersweet decision to depart the White House and embark on a new chapter in my life," Leavitt said on X.
Trump did not outline plans for who might replace her in the high-profile role.
with AP