(CNN) White House press secretary Sean Spicer resigned Friday morning after President Donald Trump named a new White House communications director, capping off a rollercoaster six-month tenure as the chief spokesman for an administration besieged by a steady drumbeat of controversy.

Newly-minted communications director Anthony Scaramucci, taking to the White House briefing room for the first time early Friday afternoon, announced that principal deputy press secretary Sarah Huckabee Sanders will take over as press secretary.

Spicer's resignation came after Scaramucci, a New York financier and former Trump campaign fundraiser, accepted the new job, a move Spicer adamantly opposed, multiple sources said. His resignation came in spite of Trump's request that he remain in this position, a White House official and top GOP advisers said.

"I am grateful for Sean's work on behalf of my administration and the American people. I wish him continued success as he moves on to pursue new opportunities -- just look at his great television ratings," Trump said in a statement Sanders delivered from the White House podium.

Trump also called Scaramucci "an important addition to this administration" in the statement read by Sanders.

RELATED - Officials: Anthony Scaramucci accepted offer to be White House communications director

The resignation marked the end of one of the most tumultuous tenures for a White House press secretary, one that saw Spicer repeatedly undermined in his role as the White House's public-facing spokesman by the President's own public statements and tweets.

"It's been an honor & a privilege to serve @POTUS @realDonaldTrump & this amazing country. I will continue my service through August," Spicer tweeted.

He told CNN on Friday that he resigned out of a desire "to give the President and the new team a clean slate."

Still, Spicer's resignation once again put a spotlight on discord inside the West Wing, with the President's top aides divided over Scaramucci's hire -- palace intrigue that Scaramucci sought to put to rest during his first briefing.

Spicer handled the responsibilities of both press secretary and communications director for much of his tenure, overseeing the White House's response to a near non-stop deluge of controversy, particularly concerning the widening federal investigation into potential ties between Trump campaign associates and Russian officials.

White House chief of staff Reince Priebus introduced Scaramucci as the new communications director to a round of applause, according to a source in the room.

The source told CNN that Spicer said Scaramucci was going to do a great job and will help with transition. He thanked the team, who gave him a round of applause. The source added that Spicer was really upset but handled the introduction for Scaramucci well.

White House staffers were "shocked" by Spicer's sudden resignation, two administration officials told CNN.

Trump wanted Scaramucci in the White House

Scaramucci's hiring began to come together Thursday night, but as news of the hire began to leak, Spicer, Priebus and chief strategist Steve Bannon found themselves largely in the dark -- unaware of the President's already firm intention to tap Scaramucci for the top communications post, largely at the urging of his son-in-law and senior adviser Jared Kushner and his daughter Ivanka Trump.

Priebus, whose fraught relationship with Scaramucci is well-known, said Friday that he supports the new communications director "100%."

"We go back a long way and are very good friends," Priebus said. "All good here."

But Scaramucci's appointment rocked a West Wing that was deeply divided over Scaramucci's hire, with sources telling CNN that both Priebus and Bannon fiercely opposed Scaramucci's hire while the President's son-in-law and daughter, who are both top advisers, encouraged the move.

Trump has been pushing for Scaramucci to come in for a while, according to a source familiar with the decision.

That source told CNN that since the communications director job was open, Trump realized he would install Scaramucci in that role. This source added that Spicer worried Scaramucci wouldn't know Washington and that it would fall to Spicer to do both jobs, which he considered to be untenable.

Scaramucci pushed back on reports of any discord inside the West Wing, especially on reports that his relationship with Priebus has been frought.

"Reince and I have been personal friends for six years," Scaramucci said. "We are a little bit like brothers where we rough each other up once in a while. But he's a dear friend."

Scaramucci said he "would have loved" for Spicer to stay on in the administration, but said he respected Spicer's decision to "clear the slate" for him. He also called Bannon "one of the smartest people I know."

"I don't have any friction with Sean, I don't have any friction with Reince," Scaramucci said.

Still, Scaramucci said he would report "directly" to the President, and that he and Priebus would work together. Sanders declined to say whether she would report directly to Priebus or Scaramucci, instead promising she and Scaramucci would work together as a "team" and noting that they both serve "at the pleasure of the president."

Spicer's job tough since Day 1

Spicer was repeatedly thrust into a combative role, ordered by the President to take to the briefing room on his first full day in office to lambast the media for coverage of the size of the crowd that attended Trump's inauguration.

The moment quickly defined Spicer's public-facing relationship with the press and his daily White House briefing quickly became must-watch TV -- including for the president of the United States, who was sometimes critical of Spicer's performance.

One White House official said he believes a "fresh start will inject some energy" in a communications operation that has been besieged for weeks by the deluge of Russia-related reports and a sense of disarray.

After being pulled away from the daily televised briefing, which had vaulted a one-time Washington hand into infamous status, Spicer told reporters he would move to an elevated role in the West Wing overseeing the communications department and press shop and said he was helping to choose his successor as press secretary.

That didn't happen, a point finally made clear Friday when Trump offered the chief communications job to Scaramucci. Not long after, Spicer resigned.

It was the latest snub for Spicer, who was repeatedly undermined by the President. But Spicer also suffered more personal jabs, like when he was kept off the small list of White House staffers who joined the President in meeting the Pope in May. Spicer, a devout Catholic, believed he would be joining the group and was excited to check the meeting off his bucket list.

Scaramucci was hired in large part because the President raved about his former fundraiser's performance as a surrogate on television, but Trump expected Spicer would continue to oversee many of the broader responsibilities of a communications director, a source close to the White House told CNN.

"Trump wanted Scaramucci on television as a surrogate for the White House and wanted to give him more of a formal title. There was simply no understanding by the President that the communications director title comes with lots of responsibilities, not just going on television," the source said.

Spicer has slowly receded from the public-facing aspects of his role, turning over the majority of daily White House briefings to principal Sanders in the last month. At the same time, the White House has cut down its on-camera briefings, cutting back on the tradition of regular on-camera briefings from the White House podium.

Spicer's tenure was defined by his struggle to beat back the cascade of controversy overwhelming the administration and how he handled the difficult task of defending a president lacking any interest in sticking to a broader communications strategy other than his own.

He was repeatedly called out for issuing statements that were later proven to be false or misleading, often as a result of the President's own public pronouncements that wound up contradicting his chief spokesman.

And Spicer also served on the front line of the administration's frequent crusades against the media, often seeking to match the president's combative and confrontational tone in answering reporters' questions during White House briefings.

That knee-jerk combativeness earned him national fame and often ridicule as he was parodied on "Saturday Night Live" by actress Melissa McCarthy as a short-tempered spokesman yearning for the President's affection.

He was also defined by his own missteps.

In April, he attracted a storm of condemnation after he incorrectly argued that even Adolf Hitler did not use chemical weapons during World War II in an over-the-top attempt to demonize Syrian President Bashar al-Assad after the Syrian dictator used sarin gas against civilians. Spicer later apologized for those comments.

This story is breaking and will update.