White House press secretary Sean Spicer is resigning, effective next month.

Spicer resigned Friday morning, shortly after President Trump selected Anthony Scaramucci as communications director. Scaramucci's hiring was a factor in his resignation, as was Spicer's diminishing role in the White House, CBS News Chief White House Correspondent Major Garrett reports. A source with direct knowledge of the situation said there was a Friday White House communications meeting in which the new communications director was announced, and Spicer made the decision to resign right before the meeting when he learned Scaramucci had the job.

Spicer confirmed his resignation about two hours after the news broke on Friday, saying he will stay on until August.

Get Breaking News Delivered to Your Inbox Click here to view related media. click to expand

It's been an honor & a privilege to serve @POTUS @realDonaldTrump & this amazing country. I will continue my service through August — Sean Spicer (@PressSec) July 21, 2017

On Friday night, Mr. Trump tweeted that Spicer is a "wonderful person" who took "tremendous abuse from the Fake News Media."

Sean Spicer is a wonderful person who took tremendous abuse from the Fake News Media - but his future is bright! — Donald J. Trump (@realDonaldTrump) July 22, 2017

CBS News previously reported Spicer had been seeking a more strategic communications role in the White House in recent weeks. But he had taken more of a background presence, with White House deputy press secretary Sarah Huckabee Sanders taking over most of the White House press briefings. Spicer had been serving as communications director since May 30, when former communications director Mike Dubke left that post.

High-profile WH briefing

The White House communications office as a whole has become less and less visible. The last on-camera White House press briefing was June 29. The White House has replaced daily on-camera briefings with off-camera briefings, embargoing even the audio.

Scaramucci, a New York financier, does not have the traditional background for his new role. But recently, he scored a success likely to attract Mr. Trump's attention -- he succeeded in getting CNN to retract a story about him, and three journalists involved in the story were forced to resign.

Spicer's resignation comes in the middle of a shakeup of the White House's legal and communications teams, and as the White House attempts to move past the ever-developing Russia story. Mr. Trump's personal attorney Marc Kasowitz is out, as is Kasowitz's spokesman, although the reasons for the moves are not currently known.

Katie Walsh, who had been working for the pro-Trump non-profit America First Policies, is returning to the Republican National Committee as a senior adviser for data and digital, CBS News has learned. Walsh was close with Spicer, and was now-White House chief of staff Reince Priebus's right hand while they worked together at the RNC.

Garrett reports that Spicer's exit raises questions about the longevity of Priebus' tenure.

Spicer's own tenure as press secretary was six months and one day, the length of time Mr. Trump has been in office. In that time, Spicer has had a difficult role to fill, attempting to harmonize conflicting statements within Mr. Trump's administration, and often enough, the president's own conflicting statements.

Sanders will give an on-camera press briefing at 2 p.m.

This is a developing story.

CBS News White House Correspondent Mark Knoller, CBS News White House Correspondent Jacqueline Alemany and CBS News Political Director Steve Chaggaris contributed to this report.