President Donald Trump said in a Monday evening Twitter post that he supported and endorsed Mitt Romney for his run for a Senate seat.

That came as a surprise to many, as the former Massachusetts governor has been a frequent and harsh critic of Trump, and the now-president has called Romney "a total joke."

Trump tweet: .@MittRomney has announced he is running for the Senate from the wonderful State of Utah. He will make a great Senator and worthy successor to @OrrinHatch, and has my full support and endorsement!

Romney, who announced he would run for Senate in Utah on Friday, expressed his gratitude for the endorsement.

Romney tweet: Thank you Mr. President for the support. I hope that over the course of the campaign I also earn the support and endorsement of the people of Utah.

That acceptance itself was incongruous with what Romney had said in 2016 about Trump's endorsement from the prior presidential election.

Romney tweet: If Trump had said 4 years ago the things he says today about the KKK, Muslims, Mexicans, disabled, I would NOT have accepted his endorsement

The 2012 Republican presidential nominee is fighting criticism that he is an outsider for the Senate seat — he mentioned Utah early and often in a video message announcing his candidacy.

"I have decided to run for United States Senate because I believe I can help bring Utah's values and Utah's lessons to Washington," he said. "Utah is a better model for Washington than Washington is for Utah."

Romney is aiming to replace 83-year-old Sen. Orrin Hatch in November's election. The longtime senator announced his retirement in January even as Trump pushed him to run again.

Romney heavily criticized then-candidate Trump in a 2016 speech, calling him a "phony" and a "fraud." He warned that Trump would cause economic instability and endanger Americans abroad.

Later, Romney unsuccessfully interviewed to be Trump's secretary of State. Since then, he has publicly rebuked Trump when he supported Roy Moore, the Alabama Senate candidate accused of sexually abusing teenagers, and when the president reportedly questioned why the U.S. needed immigrants from "s---hole" African countries.

For his part, Trump has also been critical of Romney, saying in the past that he "choked like a dog" during the 2012 run for the White House, and that he is "a mixed up man who doesn't have a clue."

Some of Trump's criticism of Romney:

Trump tweet: Mitt Romney had his chance to beat a failed president but he choked like a dog. Now he calls me racist-but I am least racist person there is

Trump tweet: Mitt Romney is a mixed up man who doesn't have a clue. No wonder he lost!

Trump tweet: Failed presidential candidate Mitt Romney, the man who "choked" and let us all down, is now endorsing Lyin' Ted Cruz. This is good for me!

Trump tweet: Don't reward Mitt Romney, who let us all down in the last presidential race, by voting for Kasich (who voted for NAFTA, open borders etc.).

Trump tweet: .@MittRomney was a disaster candidate who had no guts and choked! Romney is a total joke, and everyone knows it!

Trump tweet: Mitt Romney, who was one of the dumbest and worst candidates in the history of Republican politics, is now pushing me on tax returns. Dope!

If he wins the seat and criticizes Trump while in office, Romney would mark a stark shift from Hatch. Hatch has heaped praise on the president in recent months, calling him a "heck of a leader" after the GOP passed its tax plan in December. Trump reportedly begged the 83-year old Hatch to run for re-election one more time.

This is a breaking news story. Check back for updates.

—CNBC's Jacob Pramuk contributed to this report.