Mitt Romney has been forced into a Republican primary for a US Senate seat in Utah as he looks to restart his political career by replacing the long-serving Senator Orrin Hatch.

Romney, the Republican’s presidential candidate in 2012, remains the favorite overall to win the Senate seat in November. But if he had won enough votes at the state GOP convention on Saturday he would have bypassed a primary altogether.

Instead he was edged out by state lawmaker Mike Kennedy, who got 51% to Romney’s 49 percent. Voters will decide between the two in a 26 June primary.

Romney went up against 11 other candidates at the convention, mostly political newcomers who questioned Romney’s criticism of President Donald Trump and the depth of his ties to Utah.

Kennedy, a doctor and lawyer, got big applause from the crowd as he railed against the national debt, Common Core education standards and former President Barack Obama’s health care law.

Romney, 71, asked for delegates’ votes after spending two months on the campaign trail visiting dairy farms, taking selfies with college students and making stump speeches in small towns.

After his failed 2012 presidential campaign, he moved to Utah where he is also known for his role in the 2002 Winter Olympics and for becoming the first Mormon presidential nominee of a major political party.

He has worked to keep the focus on state issues rather than his history of well-documented feuds with Trump, whom he called a “conman” and a phony during the 2016 race. Trump fired back that Romney “choked like a dog” during his own White House run. But the two men have shown signs of making peace and Romney has accepted Trump’s endorsement.