Sen. Jeff Flake (R-Ariz.) on Tuesday announced plans to retire from the U.S. Senate at the end of his term, saying he was out of step with the Republican Party in the era of President Trump.

The senator's surprise announcement came after more than a year of criticism of Trump and the direction he has taken the party, culminating in a book called "Conscience of a Conservative" that critiqued the president's character and ideology. Recent polls in Arizona found Flake trailing the Democrat's likely Senate nominee, Rep. Kyrsten Sinema (D-Ariz.), as well as potential primary challengers if he sought a second term next year.

Flake’s surprise announcement Tuesday came just minutes after Trump left the Capitol following a rare luncheon with GOP senators and hours after Sen. Bob Corker (R-Tenn.) reignited a weeks-long feud with the president over his temperament.

In an unannounced Senate floor speech Tuesday to explain his decision, Flake excoriated Trump without using his name, delivering an address that was a call to arms to like-minded conservatives and a distress call to the nation.

Sen. Jeff Flake R-Ariz.) speaks with reporters at the Capitol on Tuesday. (Chip Somodevilla/Getty Images)

“We must never allow ourselves to lapse into thinking that this is just the way things are now. If we simply become used to this condition, thinking that it is just politics as usual, then heaven help us,” Flake said. “Without fear of the consequences and without consideration of the rules of what is politically safe, we must stop pretending that the conduct of some in our executive branch are normal. They are not normal. Reckless, outrageous and undignified behavior has become excused as telling it like it is when it is actually reckless, outrageous and undignified.”

Flake’s speech echoed concerns and criticisms leveled in recent days by former presidents George W. Bush and Barack Obama and Sen. John McCain (R-Ariz.), who also pointed to the coarse nature of the nation’s politics and the character of current leaders — subtle, indirect but indisputable commentaries Trump.

The release of Flake’s best-selling book over the summer stunned his party colleagues and stoked Trump’s anger, prompting the president to renew his vows to work to defeat Flake if he sought reelection next year.

For almost a year, Flake has faced a primary challenge from Republican Kelli Ward, a former Arizona state senator who unsuccessfully challenged McCain in 2016 by raising concerns about his age and conservative bona fides. Against Flake, Ward raised similar questions about the incumbent’s political motivations and adopted the brusque nationalistic tone that Trump used successfully during his presidential campaign. She has sought Trump’s favor, but he has declined to pick a favorite Flake challenger.

At the White House, press secretary Sarah Huckabee Sanders dismissed Flake’s speech as “petty” and said he had lost so much support in Arizona he would not have been able to win reelection.

Asked for Trump’s response to Flake’s retirement, Sanders said, “I think that based on previous statements and certainly based on the lack of support that he has from the people of Arizona, it’s probably a good move.”

Sanders, invoking Corker and Flake, told reporters, “I think that the people both in Tennessee and Arizona supported this president, and I don’t think that the numbers are in favor of either of the two senators in their states.”

Corker has also decided not to seek reelection.

Flake was already considered to be among the most vulnerable GOP incumbents facing reelection next year, and the race for his seat will be a marquee contest.

Sinema, a moderate Democrat from the Phoenix area, last month announced plans to challenge Flake.

In addition to Ward, several members of Arizona’s Republican congressional delegation, including Reps. Martha McSally and David Schweikert, were said to be considering a bid, according to Arizona Republicans. Neither issued public statements Tuesday afternoon.

The Democratic Senatorial Campaign Committee said in a statement that Flake’s retirement “is another example of the divisiveness roiling Republican primaries. These dynamics will continue to hinder Republican efforts in Arizona and whatever candidate succeeds in claiming their nomination will fall short of Kyrsten Sinema.”

Despite plans to try to unseat Flake, Senate Minority Leader Charles E. Schumer (D-N.Y.), in a statement, called Flake “one of the finest human beings I’ve met in politics. He is moral, upright, and strong and he will be missed by just about everybody in the Senate.”

The 54-year old Flake is a member of the Church of Jesus Christ of Latter-day Saints and served his mission years in Namibia. He later ran the Goldwater Institute, a libertarian think tank based in Phoenix and named for Republican Barry Goldwater, the former senator from the state. Flake won a seat in the House in 2001 and served there a dozen years before winning his Senate seat in 2012.

Long before the rise of Trump, Flake was seen as one of the GOP’s stalwart conservatives, a relentless but cheerful opponent of wasteful spending — and a critic of his party when he thought it was breaking the bank. He opposed the Medicare prescription drug law, a major priority of President George W. Bush’s administration, and criticized the party for increasing the national debt.

“Republicans have adopted the belief or the principle that you spend money to get elected,” Flake told the libertarian magazine Reason in a 2006 interview, shortly before his party lost control of the House and Senate. “Staying in office, staying in power, has come to overwhelm everything.”

In 2007, Flake was removed from a plum spot on the House Judiciary Committee, a move interpreted as intraparty revenge for his criticism. But by 2011, Flake had succeeded in one of his long-held goals, banning “earmarks,” which members of Congress used to secure spending for projects in their districts.

When Flake officially announced his intentions on the Senate floor, he was watched by senators who had just come from their respective lunch meetings and sat grimly across the chamber.

On the Republican side, Senate Majority Leader Mitch McConnell (Ky.) was joined by Corker, McCain, Pat Roberts (Kan.), Rand Paul (Ky.), Todd C. Young (Ind.), Ben Sasse (Neb.) and John Barrasso (Wyo.).

Six Democrats watched from the other side of the room: Sens. Christopher A. Coons (Del.), Tim Kaine (Va.), Maggie Hassan (N.H.), Debbie Stabenow (Mich.) and Jeff Merkley (Ore.).

“It is often said that children are watching. Well, they are. And what are we going to do about that?” Flake asked. “When the next generation asks us, why didn’t you do something? Why didn’t you speak up? What are we going to say? Mr. President, I rise to say, enough.”

Flake said senators “must dedicate ourselves to making sure that the anomalous never becomes the normal. With respect, we fooled ourselves long enough that a pivot to governing is right around the corner, a return to civility and stability right behind it. We know better than that. By now, we all know better than that.”

Flake also questioned whether his party continues to embrace his brand of conservatism.

“It is clear at this moment that a traditional conservative who believes in limited government and free markets, who is devoted to free trade, who is pro-immigration, has a narrower and narrower path” in the Republican Party, he said.

When Flake concluded, Sasse started clapping loudly, prompting colleagues in both parties to stand and applaud.

McCain addressed his colleagues later, telling the chamber, “It’s been one of the great honors of my life to have the opportunity to serve with a man of integrity and honor and decency and commitment to not only Arizona but the United States of America.”

“I have seen Jeff Flake stand up for what he believes in, knowing full well that there would be a political price to pay,” McCain added.

As Senate business resumed, Flake and McCain embraced. Flake shook the hands of Barrasso and Corker. Democrats came over from their side of the chamber to shake Flake’s hand or give him a hug.

Philip Rucker and Sean Sullivan contributed to this report.