President Trump removed newly appointed White House communications director Anthony Scaramucci Monday, just over a week after the president had hired him to help force out chief of staff Reince Priebus.

The stunning move came just hours after Mr. Trump swore in his new chief of staff, retired Gen. John F. Kelly, former Homeland Security secretary.

White House press secretary Sarah Huckabee Sanders said Mr. Scaramucci “felt it was best to give Chief of Staff John Kelly a clean slate and the ability to build his own team.”

SEE ALSO: A grown-up finally takes command

“We wish him all the best,” she said in a statement.

The president fired Mr. Scaramucci because of the profanity-laced tirade in a phone call to a New Yorker magazine writer, said a source close to Mr. Trump.

The phone call, which ended up in print, included foul-mouthed attacks on Mr. Priebus and White House senior political strategist Stephen K. Bannon.

The vulgar tirade embarrassed Mr. Trump and his family, according to the source.

Mrs. Sanders said that Mr. Trump “certainly felt that Anthony’s comments were inappropriate for person in that position.”

She said the president also “didn’t want to burden Gen. Kelly“with questions about chain of command.

However, the president could still find a role for Mr. Scaramucci elsewhere in the administration.

When he was hired by his friend the president, Mr. Scaramucci made clear that he would report directly to Mr. Trump, not to the chief of staff. It wasn’t clear whether Mr. Scaramucci was insisting on the same direct access to the president upon Mr. Kelly’s new appointment.

Several news outlets reported that Mr. Scaramucci’s ouster came at the request of Mr. Kelly.

Mr. Scaramucci had the president’s blessing last week as he stepped up his criticisms of Mr. Priebus, which led to the resignation of Mr. Priebus on Thursday. The communications director even criticized Mr. Priebus as a “paranoid schizophrenic” in a profanity-laced tirade of an interview with the New Yorker.

But since then, Mr. Scaramucci had gone home to Long Island, New York, to see his newborn son. His wife, Deirdre, filed for divorce two weeks before giving birth last week.

As reporters congregated outside Mrs. Sanders’ office, former press secretary Sean Spicer emerged and, with a smile, asked if the journalists were preparing “a surprise party” for him.

He didn’t respond to questions about whether he might be staying on at the White House.

Mr. Spicer resigned July 21, telling colleagues that he didn’t want to work for Mr. Scaramucci. He agreed to stay on until the end of August.

As news broke of Mr. Scaramucci’s ouster, Mr. Kelly was attending a military Medal of Honor ceremony with other White House officials in the East Room. He was chatting with Treasury Secretary Steve Mnuchin, smiling and appearing to be in good spirits.

A Republican source close to the White House said the ouster of Mr. Scaramucci “was a top order of business for Kelly as a new chief of staff.”

“Scaramucci quickly became an embarrassing distraction who did not know anything about the job,” the source said. “The only reason Trump wanted him to have the job was to go on TV, but not outshine him with negative publicity.”

Just a month ago, Mr. Scaramucci had won praise from Mr. Trump by winning a skirmish with CNN, a network often criticized by the president as “fake news.”

The network retracted a story and accepted the resignations of three journalists involved in the publication of an article claiming Mr. Scaramucci’s link to a congressional investigation into Trump campaign officials’ purported ties to Russia.

Another Republican with knowledge of West Wing operations said the move is encouraging for a White House that has been distracted by infighting.

“It appears Kelly will be a more empowered chief of staff,” the source said. “Time will tell, but this is a good sign for the West Wing.”

• Staff writer S.A. Miller contributed to this report.