WASHINGTON—President Donald Trump Monday night endorsed Republican Mitt Romney for a Utah Senate seat, backing a GOP candidate who is a favorite within the party but who has in the past been a vocal critic of the president.

“He will make a great Senator and worthy successor to @OrrinHatch, and has my full support and endorsement!” Mr. Trump said in a Twitter post. Also on Twitter, Mr. Romney thanked Mr. Trump for the endorsement.

Mr. Romney, who was the Republic Party’s presidential candidate against incumbent Barack Obama in 2012, announced his candidacy for the Senate seat on Friday.

Mr. Trump had been a reluctant patron of Mr. Romney, who during the 2016 campaign season called Mr. Trump a “phony” and a “fraud” while urging fellow Republicans to force a contested convention to choose a different candidate. Mr. Romney also criticized Mr. Trump’s response to events in Charlottesville, Va., last year, when the president said that both white supremacist protesters and counter-demonstrators were to blame for clashes that killed one young woman. Mr. Romney said that the president had “caused racists to rejoice, minorities to weep, and the vast heart of American to mourn.”

Mr. Trump previously used Twitter to call Mr. Romney a “loser.” In June 2016 he wrote: “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.” Last year, Mr. Trump traveled to Utah to urge Mr. Hatch, whose term expires early next year, to run for another term.