Updated

President Donald Trump announced Thursday that former United Nations Amb. John Bolton will replace Gen. H.R. McMaster as his national security adviser effective April 9 -- the latest in a growing list of White House staff shakeups over the past year.

“I am pleased to announce that, effective 4/9/18, @AmbJohnBolton will be my new National Security Advisor. I am very thankful for the service of General H.R. McMaster who has done an outstanding job & will always remain my friend. There will be an official contact handover on 4/9,” Trump tweeted.

The president’s announcement came after months of speculation over whether McMaster would resign or be fired.

Bolton told Fox News' “The Story” Thursday evening, “I didn't really expect that announcement this afternoon, but it's obviously a great honor. It's always an honor to serve our country and I think particularly in these times internationally, it's a particular honor.”

But on Thursday evening, a White House official said that the president and McMaster “mutually agreed” that he would resign. The two have been discussing this for some time, the official said, noting that the timeline was expedited as they both felt it was important to have a new team in place, instead of constant speculation.

A White House official said the decision was not related to any one moment or incident, but rather the result of ongoing conversations between the two.

The official told Fox News that the move has been contemplated for some time, and was just about the “worst-kept secret” in Washington.

The president took his time to find a replacement for McMaster because he wanted the “right person.”

While Trump spoke to Bolton many times about the job, the deal was cemented in an Oval Office meeting between the two Thursday afternoon.

Bolton told Fox News' Martha MacCallum that the process of his hiring “came to a conclusion this afternoon, but ... there's still a transition. I look forward to working with H.R. and his team and the other senior members of the president's team on national security and I have no doubt there's a lot of work to do.”

Bolton has previously served as a Fox News contributor, as well as in the Republican administrations of presidents Ronald Reagan, George H.W. Bush and George W. Bush, and served as a Bush lawyer during the 2000 Florida recount.

A strong supporter of the Iraq war and an advocate for aggressive use of American power in foreign policy, Bolton was unable to win Senate confirmation after his nomination to the U.N. post alienated many Democrats and even some Republicans. He resigned after serving 17 months as a Bush “recess appointment,” which allowed him to hold the job on a temporary basis without Senate confirmation. The position of White House national security adviser does not require Senate confirmation.

Senate Minority Leader Chuck Schumer, D-N.Y., criticized Bolton's appointment.

“Mr. Bolton’s tendency to try to solve every geopolitical problem with the American military first is a troubling one,” Schumer said. “I hope he will temper his instinct to commit the men and women of our armed forces to conflicts around the globe, when we need to be focused on building the middle class here at home.”

Sen. Bernie Sanders, I-Vt., tweeted that Bolton “was too extreme to be confirmed as UN ambassador in 2005 and is absolutely the wrong person to be national security advisor now.”

Sen. Chris Coons, D-Del., a member of the Senate Foreign Relations Committee, said he was “deeply concerned” by Bolton's positions and said he hoped Bolton would “moderate his positions and work closely with our military, diplomatic, intelligence, and development professionals before rushing into armed conflict.”

In a statement, McMaster said he was “thankful to President Donald J. Trump for the opportunity to serve him and our nation as national security adviser. I am grateful for the friendship and support of the members of the National Security Council who worked together to provide the President with the best options to protect and advance our national interests.”

McMaster said he was “especially proud” to have served with National Security Council staff, who he said “established a strong foundation for protecting the American people, promoting American prosperity, achieving peace through strength, and advancing American influence.

“I know that these patriots will continue to serve our President and our nation with distinction,” McMaster said.

White House chief of staff John Kelly said McMaster is “a fine American and Military officer.”

“He has served with distinction and honor throughout his career in the U.S. Army and as the National Security Advisor,” Kelly said Thursday. “He brought and maintained discipline and energy to our vital interagency processes. He helped develop options for the president and ensured that those options were presented fully and fairly. A true solider-scholar, his impact on his country and this government will be felt for years to come.”

Bolton, who served as U.S. permanent representative to the United Nations from 2005 to 2006 and as undersecretary of state for arms control and international security from 2001 to 2005, will take over for McMaster next month.

“Thank you to Lieutenant General HR McMaster for your service and loyalty to our country. Your selfless courage and leadership has inspired all of us. Most of all, thank you for your friendship,” current U.S. Ambassador to the U.N. Nikki Haley tweeted.

A White House official said Bolton is one of the strongest voices and experts on the full range of national security issues and challenges facing the U.S.

McMaster’s retirement comes just one week after the president fired Secretary of State Rex Tillerson on Twitter, and after other high-profile administration departures. Earlier this month, Chief Economic Adviser Gary Cohn resigned amid disagreements over a round of steel and aluminum tariffs, which Trump supported.

McMaster was brought in after Trump's first national security adviser, Michael Flynn, was dismissed after less than a month in office. White House officials said he was ousted because he did not tell top advisers, including Vice President Mike Pence, about the full extent of his contacts with Russian officials.

Fox News' Kristin Brown, Chad Pergram, John Roberts, Samuel Chamberlain and the Associated Press contributed to this report.