You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Sanders, a Republican, who has worked with Trump since the early days of his unconventional run for office, is the latest in a long line of his senior advisers to leave.
The 36-year-old, who often compared the antics of the press corps to the behaviour of her three youngsters, said she wanted to spend more time with her children.
"She's a warrior," said Trump, who announced her departure on Twitter shortly before calling Sanders on stage at an event at the White House. "We've been through a lot together, and she's tough, but she's good."
He did not immediately name a replacement.
Sanders drew criticism for ending the long tradition of daily press briefings, with Trump preferring to take questions himself from reporters and command the White House stage, and relegate his staff to appearances on television to defend his policies.
Her last briefing was 94 days ago, but Trump answers questions from reporters on a near-daily basis, including two extended sessions with them on Wednesday.
Trump's first press secretary, Sean Spicer, resigned abruptly after six months, having become the butt of late-night comedy lampoons for his blustery and fact-challenged arguments for Trump.
Sanders, who had been Spicer's deputy, initially had a less combustive approach with journalists. But her fiery defences of her boss drew criticism.
In 2017, Sanders told reporters she had heard from "countless members of the FBI" who wanted Trump to fire his FBI Director James Comey - an assertion she later cast as a "slip of the tongue" during the probe of Special Counsel Robert Mueller.
Her relationship with the press corps became particularly strained a year ago after a comedian hired by the White House Correspondents’ Association for its annual dinner mocked her appearance and penchant for spinning the truth as Sanders sat nearby at the head table.
"She burns facts and then she uses that ash to create a perfect smokey eye," comedian Michelle Wolf said.
In the months afterward, she was asked to leave a restaurant in Lexington, Virginia, because of her association with the Trump administration.
Sanders called the job "the honour of a lifetime."
"I've loved every minute, even the hard minutes," she said, her voice trembling with emotion. "I have three amazing kids and I'm going to spend a little more time with them."
Sanders' role developed into that of a senior adviser and confidante of the president, one who is regularly brought into senior-level meetings.
Speculation immediately turned to whether Sanders might run for governor of Arkansas, a position once held by her father, Mike Huckabee. She grew up working on his political campaigns.
"If we can get her to run for the governor of Arkansas, I think she'll do very well," Trump said.
The current governor, Republican Asa Hutchinson, began his second and final four-year term in January this year. The state's next regular gubernatorial election would be in 2022.
"Arkansas is a very red state, the Huckabee name carries a lot of weight there and if she ran, I can’t think of anyone that would have a chance of beating her if she decided to run," said Alice Stewart, a Republican strategist in Washington who is from Arkansas and worked for Huckabee while he was governor and then on his presidential campaign.
"The Republicans in Arkansas would welcome her back with open arms, they applaud the work she’s done," Stewart said.