UPDATE: New York financier Anthony Scaramucci has been formally named White House communications director and Sarah Huckabee Sanders has been promoted to press secretary in the Trump White House's latest shake-up.
Donald Trump said in a statement read by Ms Sanders that he is "grateful" for departing press secretary Sean Spicer's "work on behalf of my administration and the American people".
He added: "Just look at his great television ratings!"
Mr Scaramucci also addressed reporters at the White House.
He called Mr Spicer "a true American patriot" and said he hopes the departing press secretary "goes on to make a tremendous amount of money".
Mr Spicer said he chose to resign from his position to give Mr Scaramucci a fresh start.
Mr Spicer said "we're at the point where" the president "could benefit from a clean slate".
He said he felt it would be best for Mr Scaramucci to be able to build his own operation "and chart a new way forward".
Mr Spicer also complimented Mr Scaramucci, who was a staple at Trump Tower during the president's transition.
Mr Spicer said of Mr Scaramucci: "It'll be great, he's a tough guy."
The departing press chief said it has been "an honour" and "privilege" to serve Mr Trump and the country.
He said in a tweet that he will continue his service through August.
Update: Sarah Huckabee Sanders is Donald Trump's new press secretary and Anthony Scaramucci is communications director, the White House has announced.
Earlier: White House press secretary Sean Spicer is resigning his position, sources have said.
Mr Spicer's decision appears to be linked to the appointment of a new White House communications director - New York financier Anthony Scaramucci.
His daily press briefings during the first six months of Donald Trump's presidency became must-see television until recent weeks when he took on a more behind-the-scenes role.
Deputy press secretary Sarah Huckabee Sanders has largely taken over the briefings, turning them into an off-camera event.
Mr Spicer spent several years leading communications at the Republican National Committee (RNC) before helping Mr Trump's campaign in the presidential election.
He is close to White House chief of staff Reince Priebus, the former RNC chairman, and several of the lower-ranking aides in the White House communications department.
Mr Scaramucci is expected to play a visible role as one of Mr Trump's defenders on television.
But Mr Spicer and other officials questioned his hiring as communications director ahead of the president's push to overhaul the tax system and other policy issues.
One of the officials said Mr Spicer objected to Mr Trump's vision for the future of the press operation.
On Mr Trump's first full day in office, Mr Spicer lambasted journalists over coverage of the crowd size at the inauguration and stormed out of the briefing room without answering questions.
His fiery demeanour and tense on-camera exchanges were mocked on Saturday Night Live, with the role of Mr Spicer being played by actress Melissa McCarthy.
Mr Priebus said he supports Mr Scaramucci "100%".
He has reportedly opposed hiring Mr Scaramucci for various administration positions but he told AP that he and Mr Scaramucci are "very good friends". He said it's "all good here" at the White House.