An overwhelming majority of Hungarians who voted in a referendum appear to have rejected the European Union migrant resettlement quotas.
But despite an extensive antimigrant campaign, initial results suggested that the turnout did not reach the necessary 50 percent, making the October 2 vote invalid.
With about 99 percent of the vote counted, more than 3.2 million voters -- or about 98 of those who cast valid ballots -- backed the government.
But turnout reached only about 43 percent, reports said.
The governing party claimed victory, saying its own projections based on exit polls showed that 95 percent of voters supported the government antimigrant position.
The deputy chairman of the governing Fidesz party, Gergely Gulyas, described the result as "a sweeping victory for all those who reject the relocation plan, for those who believe that only nation-states should remain, and for those who believe in democracy."
Prime Minister Viktor Orban, who has been a leading voice against allowing Syrian refugees and other migrants to settle in Europe -- erecting two border fences to keep out illegals, earlier downplayed the significance of the low turnout.
Orban said there would be "legal consequences" regardless, without giving further details.
Orban later hailed the "outstanding" result of the vote and said that the EU could not not force Hungary to accept migrants on its soil.
"Brussels cannot force its will on Hungary," Orban told his supporters in Budapest.
Analysts said that the result was a blow to Orban.
"The stakes were too high, they had led a very harsh campaign for months -- even in June, during the European football championships, there were huge TV advertising campaigns during the halftime breaks. Everyone thought Orban could do it -- so this is a failure for him," Robert Laszlo, an election and polling specialist at the Budapest-based Political Capital Institute, told The Guardian.
The radical-right opposition party Jobbik said the referendum was "a fiasco" and called on Orban to resign if the vote proved invalid.