Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — John Bolton, the former U.S. ambassador to the United Nations and undersecretary of state for international security, will replace Army Lt. Gen. H.R. McMaster as national security adviser, President Donald Trump announced in a tweet Thursday.

"I am pleased to announce that, effective 4/9/18, @AmbJohnBolton will be my new National Security Advisor," Trump tweeted. "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 added.

John Bolton arrives at the Conservative Political Action Conference in Oxon Hill, Maryland, in February 2017. Alex Brandon / AP file

Bolton, who served in high-level positions in the administrations of presidents Ronald Reagan, George H.W. Bush and George W. Bush, is known for his hard-line foreign policy views and has written in support of attacking North Korea.

"I didn't really expect the announcement this afternoon, but it's obviously a great honor," Bolton said after Trump's announcement in an appearance on Fox News, where he is a contributor. "It's always an honor to serve our country."

Bolton said later in a statement that the appointment was "an honor."

"The United States currently faces a wide array of issues and I look forward to working with President Trump and his leadership team in addressing these complex challenges in an effort to make our country safer at home and stronger abroad," he said.

My official statement on accepting @POTUS' request to become the next National Security Advisor. pic.twitter.com/lptI5AwSeU — John Bolton (@AmbJohnBolton) March 23, 2018

McMaster, in a statement provided by the White House, said he was "requesting retirement" from the Army, effective this summer, and would then leave public service altogether.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"Throughout my career it has been my greatest privilege to serve alongside extraordinary servicemembers and dedicated civilians," he said.

Reaction from both parties was swift and strong.

"Selecting John Bolton as national security adviser is good news for America's allies and bad news for America's enemies," Sen. Lindsey Graham, R-S.C., said in a statement, adding that Bolton "has a firm understanding of the threats we face from North Korea, Iran and radical Islam."

However, Democratic Rep. Barbara Lee of California — the only member of Congress to have voted against the 2001 authorization of use of force that granted the president broad war powers in the wake of the terrorist attacks of Sept. 11, 2001 — issued a dire warning.

"John Bolton was easily one of the most extreme, pro-war members of the Bush administration. Just imagine what havoc he could wreak whispering in Donald Trump's ear," Lee said. "I hear the drumbeats of war."

McMaster's exit comes after months of speculation about not whether, but when, McMaster would part ways with the administration. NBC News reported on March 1 that the administration was preparing to replace its second national security adviser as early as the end of the month.

His departure is also the latest in a string of firings and resignations from the Trump White House. Only last week, Trump announced that he'd fired Secretary of State Rex Tillerson and appointed CIA Director Mike Pompeo to replace him.

The National Iranian American Council, a nonprofit based in Washington that supports the Iran nuclear agreement, also condemned Bolton's appointment Thursday.

"Donald Trump may have just effectively declared war on Iran. With the appointment of John Bolton and nomination of Mike Pompeo at State, Trump is clearly putting together a war cabinet," the organization's president, Trita Parsi, said in a statement.

Trump has previously threatened to withdraw the United States from the Iran deal, which was put in place under President Barack Obama to help curb the country's nuclear ambitions in exchange for sanctions relief, and its fate remains uncertain.

McMaster entered the administration after Trump's first national security adviser, Michael Flynn, resigned after 24 days on the job amid revelations that he had lied to Vice President Mike Pence about his communications with a top Russian diplomat.

Flynn pleaded guilty in December to lying to the FBI about his communications with Russia. While Trump enjoyed a close relationship to Flynn — stemming in part from their days on the 2016 campaign trail together — that sort of relationship never materialized with McMaster, leading to tension between the decorated military general and his commander in chief.

At times, those tensions spilled into public view — like last month when Trump took to Twitter to dispute McMaster's comments about Russian meddling in the 2016 election. During a speech at the Munich Security Conference, McMaster said evidence of Russian meddling was "incontrovertible" — a more direct confirmation of interference than the president has ever given.

What McMaster "forgot to say," Trump chastised in the tweet, was "that the results of the 2016 election were not impacted or changed by the Russians and that the only Collusion was between Russia and Crooked H, the DNC and the Dems." "Crooked H" was read as a reference to Hillary Clinton, whom Trump defeated in the presidential election.

Bolton, who will become the administration's third national security adviser in just more than a year, will join the White House as Trump approaches one of the most high-stakes periods of his presidency. Earlier this month, Trump accepted an invitation from North Korean leader Kim Jong Un to meet, although no location or firm timetable has been set.

Trump acknowledged a connection to Bolton during the presidential campaign, telling Chuck Todd on "Meet the Press" in 2015 that he watched "the shows" for military advice.

When pressed to name a "go-to" military adviser, Trump said: "Probably there are two or three. I like Bolton. I think he's a tough cookie, knows what he's talking about."

In addition to having served as U.N. ambassador and undersecretary of state during President George W. Bush's administration, Bolton, 69, was assistant attorney general in Reagan's second term and assistant secretary of state for international organizations in the administration of Reagan's successor, George H.W. Bush.