(Reuters) – Hungary’s parliament on Tuesday narrowly rejected a plan by Prime Minister Viktor Orban to ban the resettlement of migrants in the country, a setback for the maverick leader that could weaken him in his fight against EU migration policies.

In a rare parliamentary defeat for Orban, his proposed constitutional amendment won only 131 votes in the 199-seat parliament, just short of the necessary two-thirds majority of 133.

The far-right Jobbik party sealed the bill’s rejection by boycotting the vote. But it held out a lifeline to Orban by saying it would throw its support behind the ban if he scrapped a separate scheme allowing foreigners to buy residency rights.

Orban’s right-wing Fidesz party said its presidency would meet to discuss its next move. Backing down to Jobbik would be politically difficult, as Orban’s chief of staff has previously described its demand as blackmail.

Orban’s determination to keep out migrants and refugees, including by building razor-wire border fences, has angered his fellow European Union leaders and complicated their task as the EU struggles to cope with an influx of 1.4 million people since the start of 2015, many fleeing conflicts like the war in Syria.

Orban had said the amendment was needed to honor an October referendum in which more than 3 million Hungarians, an overwhelming majority of those who voted, rejected EU quotas stipulating how many migrants member states must accept.

He said that even though the referendum was not legally binding because of low turnout, it gave him a strong political mandate to stop Brussels imposing the measure.

“This vote today is a temporary fiasco (for Orban), similarly to the referendum which was invalid,” said Robert Laszlo, a political analyst at thinktank Political Capital.

Laszlo said at home, the failure of the amendment was unlikely to weaken Orban, whose party enjoys a strong lead in opinion polls ahead of 2018 elections.

“In Brussels, he will not be able to sell this as a success, there his positions will weaken,” he added.

RESIDENCY BONDS

Following the vote, Jobbik reiterated its demand that the government scrap a residency bond scheme under which foreigners can buy the right to live in Hungary for at least five years on payment of up to 300,000 euros ($331,000).

Almost 10,000 Chinese have taken advantage of the scheme to move to Hungary, as well as affluent investors from Russia and the Middle East. But Jobbik contends that some of the new arrivals pose a security threat.

“The moment that Fidesz, the government scraps the bond programme, Jobbik is ready to back the amendment of the constitution within 24 hours,” Jobbik leader Gabor Vona told reporters.

During the vote, Jobbik MPs held up a large banner that said: “Those are the traitors who let in terrorists in exchange for money.”