David Cameron has suffered a humiliating defeat after EU leaders voted overwhelmingly in favour of nominating Jean-Claude Juncker as the next president of the European commission.

Minutes after the prime minister announced that EU leaders may live to regret the appointment of Juncker, the European council president, Herman Van Rompuy, tweeted that the former Luxembourg prime minister had been nominated.

"Decision made," Van Rompuy tweeted. "The European council proposes Jean-Claude Juncker as the next president of the European commission."

Herman Van Rompuy (@euHvR) Decision made. The European Council proposes Jean-Claude Juncker as the next President of the European Commission #EUCO

The vote in favour of Juncker was passed by 26 to two after Cameron won the support of only one other EU country – Hungary.

Juncker now becomes the European commission president designate. He can only formally assume office if he wins the support of a simple majority of MEPs.

The decisive support for Juncker after an unprecedented vote among EU leaders for a commission president marks a major setback for Cameron, who had thought key EU allies would oppose his nomination. But Angela Merkel, who had voiced doubts about Juncker, threw her support behind him after a domestic backlash when the German chancellor suggested last month that other candidates could be considered.

The British prime minister, who told EU leaders over lunch that Juncker's appointment would mark a "sad moment", tweeted his frustrations from the summit in Brussels.

"I've told EU leaders they could live to regret the new process for choosing the commission president. I'll always stand up for UK interests."

David Cameron (@David_Cameron) I've told EU leaders they could live to regret the new process for choosing the Commission President. I'll always stand up for UK interests.

Before the vote Cameron told EU leaders they may live to regret the appointment, warning them of the grave consequences for public opinion in Britain.

In some of the strongest remarks by a British prime minister at an EU summit, Cameron condemned a "backroom deal" to appoint Juncker, who was being "railroaded" through against the wishes of Britain and Hungary.

Cameron, who warned of "wafer thin" British support for the EU, told EU leaders: "[Jean-Claude Juncker] is the ultimate Brussels insider who has been at the table for the last two decades of decisions. If you want change is that the type of person you want for the future?"

Cameron outlined his concerns about Juncker in a brief meeting with Merkel shortly before the summit. A British official said Cameron told Merkel that the appointment of Juncker would mark a "worrying moment for Europe and for Britain".

Cameron later made what officials described as a "strong and passionate intervention" at the lunch. The official said of the prime minister's remarks: "He thinks today is a sad moment for Europe and is disappointed we have reached this point."

David Cameron talks to outgoing European commission president, José Manuel Barroso before the vote at the EU summit. Photograph: Yves Logghe/AP

The prime minister suggested the appointment of Juncker would undermine his attempts to persuade voters that he can reform the EU.

Prior to the lunch, the official said of Cameron: "[On] the debate in Britain about Britain's role and its place in the EU, he will remind people [that] of the plan he has for dealing [with that], there is wafer-thin support – the strategy he set out in [his January 2013] Bloomberg speech, remind them it is working and there is a clear and steady increase in the numbers saying they want the UK to stay in the EU from the speech to the recent polls."

Cameron objected to Juncker's appointment on two grounds: that he will not be able to lead EU reform, and that the spitzenkandidaten system has no legitimacy. The system was devised by European parliament leaders who are using the powers in the Lisbon treaty that say EU leaders need to take account of last month's European parliamentary elections in nominating a candidate. Juncker is the candidate of the centre-right European People's party, the largest group in the parliament.