Leavitt said she was stepping down to spend more time with her two young children. She gave birth to her second child, a daughter, in May and recently returned from maternity leave.
Trump praised her tenure, calling her "one of the best White House Press Secretaries in the History of the Office" and crediting her with being a strong advocate for his administration.
Leavitt described her time at the White House as "the honor and adventure of a lifetime."
From Trump campaign to White House podium
Leavitt joined Trump's 2024 presidential campaign and later served as its transition spokeswoman. Trump selected her as his press secretary after winning the election, making her the youngest person ever appointed to the position.
Her tenure quickly became closely associated with Trump's combative approach to the media. She frequently clashed with reporters during briefings and became one of the administration's most recognisable public faces.
Former Trump deputy press secretary Harrison Fields praised her ability to communicate the president's message, saying: "Few could or will ever compare to Karoline," and describing her as someone who "not only spoke Trump fluently, she knew how to feed the media beast in a cunning, audacious, and successful way that, most importantly, played to her audience: the president."
A different approach to the White House press corps
During Leavitt's roughly 18 months as press secretary, the administration significantly changed how journalists gained access to the president.
The White House began selecting which reporters could cover Trump, moving away from the traditional press-pool system managed by the White House Correspondents Association.
The administration also created a dedicated "new media" position in the briefing room for podcasts, newsletters and smaller digital outlets. Supporters viewed the move as an acknowledgement of how audiences now consume news, while press-freedom advocates questioned whether access could be used to favour media organisations seen as sympathetic to Trump.
Leavitt will now move into an advisory role as the administration heads towards the November midterm elections. Trump said she would help shape the future direction of his "Make America Great Again" movement.
Exit comes amid questions over Trump's secret flight
Leavitt's departure comes days after reports that the White House used an elaborate security operation to conceal Trump's movements while leaving a NATO summit in Türkiye.
According to a Washington Post report cited in the source material, Trump was secretly moved from the aircraft that journalists and officials believed he was travelling on to a smaller military plane. The transfer reportedly took place inside a catering truck after US officials received intelligence about a potential Iranian assassination threat.
The journalists and staff aboard the original aircraft were reportedly unaware that Trump had already left, marking an unusual departure from established presidential travel arrangements.
(With inputs from Reuters)