Mr. Flake’s support for immigration, which in his Tuesday retirement speech he characterized as a traditional conservative position, has roiled some of his fellow Republicans over the years. He ran afoul of Tea Party activists during his 2012 campaign and was criticized for being a member of the Gang of Eight, a bipartisan group of senators tasked with immigration reform in 2013.

Breitbart News characterized him as a supporter of “amnesty.” The conservative commentator Ann Coulter listed him among “our stupidest Republicans” and proposed that someone challenge him in the primary race. And the conservative radio and TV personality Glenn Beck, a former admirer of Mr. Flake, called him a “Tea Party favorite who quickly lost his soul after taking his oath of office.”

Immigration aside, Voteview, which places congressional votes on an ideological map, has consistently ranked Mr. Flake among the most conservative members of his party. According to this metric, Mr. Flake was the second most conservative member of the House from 2001 to 2005 before slipping to No. 3, where he remained until he joined the Senate. Currently, only two senators — Rand Paul of Kentucky and Mike Lee of Utah — are more conservative than Mr. Flake, according to Voteview.

Govtrack, a website that monitors legislative actions, assigns an ideological score based on bill sponsorship. Mr. Flake has ranked among the middle the pack by this measure, ranging from No. 17 in 2013 to No. 32 in 2015.

While Mr. Flake has consistently criticized Mr. Trump since the 2016 presidential election, he has voted in support of the president 90 percent of the time — a fact that Mr. Trump noted in his remarks on Wednesday and said was “good.”