Washington • Sen. Mitt Romney on Tuesday broke with Republican ranks and cast the lone GOP vote against a judicial pick by President Donald Trump because the nominee had disparaged then-President Barack Obama.

The Senate confirmed Michael Truncale 49-46, with Romney joining Democrats in opposing the nomination.

Truncale, who will serve as a federal judge in Texas, had called Obama an “un-American imposter” and railed against liberal policies and judges and Democrats.

Romney, a Utah Republican and the 2012 GOP presidential nominee who has been an occasional critic of Trump, said Truncale's past rhetoric is not indicative of the temperament a federal judge should have.

He made particularly disparaging comments about President Obama,” Romney told reporters, according to Politico. “And as the Republican nominee for president, I just couldn’t subscribe to that in a federal judge. This was not a matter of qualifications or politics. This was something specifically to that issue as a former nominee of our party.”

Carl Tobias, a professor at the University of Richmond law school, praised Romney for " living up to his own principles," adding that he hopes the Utah Republican "will do so when voting on other similar nominees — a stance too few other GOP senators have assumed.”

Several groups, from civil rights and women’s rights advocates to liberal associations, had opposed Truncale’s nomination, citing his past comments ranging from immigration to abortion rights to coed bathrooms.

“With regard to immigration, we must not continue to have the maggots coming in,” he once said, though later argued he used the word “magnets.”

Truncale also claimed he marched in an anti-abortion rally.

In written comments to the Senate Judiciary Committee, Truncale clarified his comment about Obama as “merely expressing frustration by what I perceived as a lack of overt patriotism on behalf of President Obama.”

Romney, in his brief comments to reporters, didn’t touch upon those other issues.

The freshman senator has had a back-and-forth relationship with Trump, whom he called during the 2016 Republican primaries a “phony, a fraud.” The two, though, later sat down for dinner after Trump won the election and was considering Romney for secretary of state.

So far in office, Romney has said he'd support the president when he agreed and speak out when he didn't.

Romney opposed the nomination of former pizza executive Herman Cain to the Federal Reserve (Cain was ultimately never nominated) and has said that he wants special counsel Robert Mueller to testify, a move opposed by Trump and his team.