Hungary's radical right party Jobbik dealt all-powerful Prime Minister Viktor Orban a rare defeat on Tuesday as it blocked his bid to change the constitution to bar the resettlement of refugees.
While all 131 MPs of Orban's ruling right-wing coalition voted in favour, the landmark bill failed to pick up an extra two votes to reach a required two-thirds majority in the 199-seat parliament.
The rejection is an unexpected setback for the populist strongman who has already amended the constitution six times since winning a supermajority in 2010 and reelection in 2014.
It follows a divisive referendum last month, in which 3.3 million voters backed Orban's rejection of the European Union's plan to relocate migrants via mandatory quotas.
The ballot, however, was deemed invalid due to low turnout in the nation of nearly 10 million people.
Observers warned that Tuesday's defeat risked seriously wounding Orban's political ambitions.
"After the referendum, this is the second time that the scenario that Orban wanted is not being realised. For a party that prides itself on being effective, this is a rare and significant defeat," analyst Csaba Toth told AFP.
The vote could set the scene for a growing power struggle between Orban's Fidesz and Jobbik ahead of the next scheduled general election in 2018.
Jobbik has been a natural ally in Orban's hardline campaign to stop Hungary taking in any of the hundreds of thousands of migrants who arrived in Europe in 2015.
But it is currently vying with the Socialists as the second most popular party in the country, and laid a surprise ambush for Orban earlier this month.
Spotting a rare opportunity for leverage, Jobbik's leader Gabor Vona recently announced it would only vote for the bill on the condition that the government scraps a controversial cash-for-residency bond scheme for wealthy foreigners.
Jobbik said the scheme, often sold by shady offshore companies, posed a national security risk that could be exploited by Islamic State jihadists.
Orban, caught offguard by the ultimatum, initially said he would "consider" Vona's gambit, but later told parliament that the government "would not give in to blackmail".
During Tuesday's vote, Jobbik lawmakers held up a banner reading "The traitor is he who lets in terrorists for money", next to the Fidesz logo in an Arabic-style font.
Vona told reporters after the ballot he would be willing to vote for the constitutional amendment within 24 hours if the residency bonds are phased out.
"Tuesday's defeat is self-inflicted," said Toth.
"(Fidesz) thought that not making a compromise with Jobbik is more important than getting the constitution change approved," he added.
Asked if he would resubmit the bill, Orban said "the Fidesz board will decide".
Orban has emerged as the standard-bearer of those opposed to German Chancellor Angela Merkel's "open-door" policy, in the wake of the bloc's worst migration crisis since World War II.
Although the October 2 national ballot was declared void, Orban still hailed the outcome as "a sweeping victory" over "Brussels bureaucrats" and vowed to change the constitution to "reflect the will of the people".
He personally submitted a draft amendment to parliament the week after the referendum, proposing to ban migrant settlement without the approval of the national assembly and authorities.
"Foreign populations cannot be settled in Hungary," the amendment reads. "Individual foreigners (not including EU nationals) can only live in Hungary with the approval of Hungarians," it continues.
Some observers say the rejection could still be a win for Fidesz, whose poll ratings have soared over its hardline migrant stance.
"Fidesz will dominate the public discourse with its argument that 98 percent said 'No' (to the EU quota plan) and now no other party but Fidesz is ready to take action on that," Bulcsu Hunyadi told AFP.