Sean Spicer quit his job as White House press secretary Friday after President Trump decided to tap Anthony Scaramucci as the White House communications director, according to two White House officials.

Spicer objected to the hiring, said the two officials, who spoke on condition of anonymity because they weren't authorized to speak publicly. He had taken on the communications director duties after the resignation of Mike Dubke back in May.

Deputy press secretary Sarah Huckabee Sanders will replace Spicer as press secretary. Scaramucci announced the news himself during Friday's briefing.

“Slow news day?” Sanders asked as she took the podium in a briefing room packed with reporters and clicking cameras.

She promised to "always work to operate at the highest level and with as much integrity as possible."

According to one official, Spicer had sought the communications director job himself, with the understanding that a new press secretary would be brought in to work under him. Spicer interviewed candidates last month.

Months ago, Spicer, chief of staff Reince Priebus and others blocked Scaramucci from getting a position at the White House, saying he lacked the necessary experience and skills, the official said.

Spicer tweeted on Friday that it had been an "honor and privilege" to serve in the administration and that he would remain in his job through August.

During the briefing, Scaramucci wished Spicer well, saying, “I hope he goes on to make a tremendous amount of money.”

Scaramucci said he appreciated that Spicer wanted to give him a clean slate by leaving, but disputed that there’s any bad feelings.

“I don’t have any friction with Sean,” he said. “I don’t have any friction with Reince.”

Sanders seconded the idea of Spicer leaving to give Scaramucci a fresh start.

"He understands that the president wanted to bring in and add new people to the team and Sean felt like it’d be best for that team to start with a totally clean slate," Sanders said. "It speaks volumes about who is to be willing to do that."

Scaramucci also pushed back on the idea that White House is having trouble.

“This ship is going in the right direction,” Scaramucci said. “We’ve got to just radio signal the direction very, very quickly.”

Scaramucci insisted that he and chief of staff Priebus are a "team."

"If teammates don't have disagreements about certain things, then they won't get to the championship," he said.

Priebus told media outlets on Friday that he is "100%" behind Scaramucci's appointment.

Sanders also pushed back on reports that the turnover on the White House staff had led to chaos.

"No, I don’t see it as chaotic," she said. "If you want to see chaos, you should come to my house early in the morning when my three kids are running around."

Spicer's resignation came exactly six months after he gave his first briefing on Jan. 21. He is one of the shortest-serving press secretaries of all time, though his tenure was longer than that of Jerald terHorst, who served under President Ford for one month, and Jake Siewert, who was the press secretary for the final four months of the Clinton administration.

Rumors began to circulate that the White House was considering making a major staff shakeup in May, in the wake of Trump's abrupt firing of James Comey.

Trump blamed his press team, including Spicer, for failing to arrest the public firestorm that ensued after Trump dismissed the FBI director. Comey had been running the investigation into the Trump campaign's possible collusion with Russia during the presidential election — though the press team had been left in the dark about the president's sudden decision to fire Comey.

The strain in Spicer's relationship with the president was perhaps at its most public display when Trump, on his first foreign trip in office, did not invite Spicer to a meeting with Pope Francis at the Vatican in late May. Spicer, a devout Catholic, reportedly thought he would be included in the entourage, but found out at the last minute that he would not join Trump, members of the first family and other administration officials. According to CNN, meeting the pope was "all he wanted."

Even in the earliest days of the Trump administration, Spicer had a rocky rollout as spokesman with an antagonistic first appearance in the White House briefing room.

The day after Trump’s inauguration, Spicer called reporters in on Jan. 21 for an unplanned Saturday briefing to deliver a short and combative statement accusing the news media of "deliberately false reporting" by misrepresenting inaugural crowd sizes and artwork in the Oval Office. The evidence that Spicer cited did not match numbers from official sources, particularly with regard to crowd sizes.

Spicer’s ongoing combativeness with the media was lampooned on Saturday Night Live in recurring appearances by Melissa McCarthy, who portrayed Spicer.

He was also widely criticized in April for comments likening Syrian President Bashar Assad to Nazi leader Adolf Hitler, who was responsible for the Holocaust that killed six million Jews and others including Gypsies, gay and disabled people. Spicer said even someone as despicable as Hitler didn’t sink to using chemical weapons as Assad did. He later apologized, calling his own comments “insensitive.”

Spicer, who had served as the Republican National Committee liaison to the Trump campaign and a transition spokesman, called it an “amazing honor” when Trump tapped him to be White House press secretary. He initially was also tasked with being communications director when campaign aide Jason Miller, who’d been given the job, abruptly announced he no longer wanted it.

Spicer came to the post after six years at the Republican National Committee and 15 years in other communication jobs in Washington.

The RNC credited Spicer with helping lead a “dramatic turnaround” after arriving in 2011 when the RNC was deep in debt and had a “badly tarnished brand.”

Spicer helped improve Republicans’ social media efforts, surrogate operations, engagement with minority media outlets and communications training.

He’d previously served as assistant U.S. trade representative for President George W. Bush, handling media and public affairs.

Spicer also worked in various communications roles on Capitol Hill.

Spicer, who grew up on Rhode Island, doesn’t come from a political household. His family discussed issues, but not politics, at the dinner table.

Although Spicer became interested in government and politics in high school, he initially studied Japanese in college in hopes that he could combine that with economics to make a ton of money on Wall Street. But when that failed to excite him, Spicer started taking government classes instead.

He volunteered for local political campaigns and later lived in a trailer with no electricity in New Jersey and an attic in Connecticut to work on congressional campaigns.

Spicer has said he was drawn to the communications side of politics because of the adrenalin rush.

“I love the immediacy of it,” he told David Axelrod in a January interview for Axelrod’s podcast, "The Axe Files.” As Spicer put it: “It’s never boring. I find that exhilarating.”

After working on a number of campaigns and then in Congress, Spicer joined the U.S. Navy Reserve in 1999 out of a sense of “wanting to belong to something that gave back.”

“I had served in government,” Spicer said, “but I think there’s something very, very unique about the military that I was drawn to."

He received a master’s degrees in national security and strategic studies from the Naval War College in 2012. A Navy commander, he’s assigned to the Joint Staff’s naval reserve contingent in D.C. where he fulfills his duty.

Contributing: David Jackson

Read more:

Sean Spicer still looking for his replacement ... but remains press secretary for now

When Washington reporters ask hard questions, Sean Spicer turns to Skype