RIJEKA, Croatia — The prime minister of Slovenia, who surged to power as a political novice in 2014 on promises of an economic recovery, has resigned after the country’s highest court stalled an infrastructure project that was a crucial part of his agenda.

Hours after the ruling on Wednesday, the prime minister, Miro Cerar, announced that he would step down, and he made it official on Thursday in a note to the parliament. He said the decision by the Supreme Court of Slovenia was “a fresh blow” to the center-left government’s flagship development plan, blaming “those who want to halt Slovenia’s economic growth at any cost.”

“I do not want to be part of that story,” Mr. Cerar said.

With a history that parallels Emmanuel Macron’s sudden rise in France, Mr. Cerar, 54, led his hastily assembled party — now known as the Modern Center Party — to success in the 2014 elections. His party won the largest share of seats, and formed a coalition government with two smaller parties, the Democratic Party of Pensioners and the Social Democrats.

He campaigned on promises to return decency to politics and to curb an economic downturn that had hit hard in Slovenia, a member of the European Union with a population of about two million.