Donald Trump and John Kelly. Chip Somodevilla/Getty Images President Donald Trump on Friday replaced White House chief of staff Reince Priebus with Homeland Security Secretary John Kelly.

"I am pleased to inform you that I have just named General/Secretary John F Kelly as White House Chief of Staff," Trump wrote in the first of two tweets just before 5 p.m. ET. "He is a Great American and a Great Leader. John has also done a spectacular job at Homeland Security. He has been a true star of my Administration."

In a third tweet, Trump thanked Priebus "for his service and dedication to his country."

"We accomplished a lot together and I am proud of him!" Trump said.

CNN reported that Priebus offered Trump his resignation on Thursday.

Priebus released the following statement on Friday:

"It has been one of the greatest honors of my life to serve this President and our country. I want to thank the President for giving me this very special opportunity. I will continue to serve as a strong supporter of the President's agenda and policies. I can't think of a better person than General John Kelly to succeed me and I wish him God's blessings and great success."

Trump told reporters more about the move as he returned from Long Island after giving a speech there Friday afternoon.

"Reince is a good man," Trump told pool reporters after he got off Air Force One. "John Kelly will do a fantastic job. General Kelly has been a star, done an incredible job thus far, respected by everybody. He's a great, great American."

White House press secretary Sarah Huckabee Sanders called Kelly "one of the true stars of the administration" who "has helped seal the border and reduced illegal immigration by 70%."

"He is respected by everyone, especially the people at the Department of Homeland Security," she said. "The entire administration loves him, and no one is comparable. He will begin on Monday morning and a Cabinet meeting will follow his swearing in Monday morning."

Sanders said Trump thanked Priebus for his service.

"They accomplished a lot together," she continued. "He was loyal in his dedication to the president. The president thanks him and his family for his great service to the country, and he will always be a member of the Trump team."

Sanders told reporters that conversations about the shakeup started between Trump and Priebus about two weeks ago.

The episode marked the end of a weeklong saga involving Priebus and new White House communications director Anthony Scaramucci. Priebus had worked hard to block Scaramucci's appointment, but Trump decided to hire him anyway. Sanders denied that Priebus' resignation had to do with Scaramucci.

Immediately after Scaramucci's hiring, White House press secretary Sean Spicer announced he was resigning. Spicer was Priebus' closest White House ally based on both of their past work for the Republican National Committee. (Spicer was the chief strategist and communications director, while Priebus was the chairman.)

The New York Times reported on Friday that Priebus was pushed out as Trump became convinced he was not strong enough for the role. Trump had discussed bringing in "a general" to lead his administration, according to The Times, and selected Kelly, a retired Marine four-star general whose work leading the Department of Homeland Security has pleased the president.

But Kelly's appointment leaves a gap at the Department of Homeland Security, and his successor will have to be confirmed by the Senate.

Priebus joined Trump on his trip to Long Island, where he gave a speech focused on his administration's efforts to fight the MS-13 street gang. Also on the flight was also Scaramucci, who had savaged Priebus in a New Yorker interview published less than a day earlier.

In that interview, Scaramucci called Priebus a "f------ paranoid schizophrenic, a paranoiac" and said the chief of staff would be resigning soon.

Scaramucci became incensed at Priebus on Wednesday after a Politico report detailed Scaramucci's financial disclosures, which was publicly available from Scaramucci's stint at the Export-Import Bank. Scaramucci, who did not know that at the time, said in a now-deleted tweet that the report was illegally leaked and that he would contact the FBI and the Justice Department. He also tagged Priebus and wrote "#swamp."

Scaramucci called The New Yorker's Ryan Lizza that day because he was angered by one of the reporter's tweets, which cited a "senior White House official" who said Scaramucci was having dinner at the White House with the president, first lady Melania Trump, former Fox News executive Bill Shine, and Fox News host Sean Hannity.

On Thursday night, The Washington Post reported that Scaramucci and his allies were compiling a diagram of news outlets to which they believed Priebus leaked information, citing a White House official. They planned to present their findings to Trump on Friday, the official told The Post.

House Speaker Paul Ryan — a fellow Wisconsinite and close ally — released a statement on Priebus' departure shortly after it was announced.

"Reince Priebus has left it all out on the field, for our party and our country," Ryan said. "Here is a guy from Kenosha, Wisconsin, who revitalized the Republican National Committee and became White House chief of staff. He has served the president and the American people capably and passionately. He has achieved so much, and he has done it all with class. I could not be more proud to call Reince a dear friend."

Ryan congratulated Kelly and said he looked forward to working with him.