Vast majority of those who did turn out voted against refugee-sharing plan
Hungarians have voted overwhelmingly to reject the EU's migrant quota plan but the result has been declared invalid by the country's National Committee.
For it to stand, at least 50% of the country's eight million people were required to vote.
But the turnout was only around 44%, seemingly a setback for Hungary's right-wing prime minister who is strongly against the EU proposal.
However, the vast majority of those who voted - about 98% - supported PM Viktor Orban in rejecting the bloc's plan to share out migrants who have been granted asylum.
He called the result "outstanding" and said the EU "cannot force" his country to accept refugees and migrants.
The National Committee earlier declared the referendum invalid, meaning its parliament is not compelled to vote on the outcome.
The government, though, says it will be put it to parliament regardless and therefore the vote could still have an important impact.
The question on the ballot was: "Do you want the European Union to be entitled to proscribe the mandatory settlement of non-Hungarian citizens in Hungary without the consent of the National Assembly (Parliament)?"
Mr Orban, who is regarded as a renegade by some fellow EU leaders, had called on his citizens to vote "no" in the ballot.
He wanted them to reject the system designed to share the burden of the migrant influx by distributing successful asylum seekers evenly among European countries.
Edit Piros, an ethnic Hungarian from Romania, receives a ballot paper before voting in the referendum | Photo: PA Images
Voters were asked whether or not to accept EU quotas for migrants and refugees rather than whether they should continue to be members of the EU itself.
Hungary found itself at the centre of the 2015 migration crisis, with tens of thousands of refugees and migrants trying to pass through the country to reach Northern Europe.
Budapest's Keleti train station was a bottleneck with migrants - most from Syria, Iraq and Afghanistan - trying to board trains bound for Munich in Germany.
Hungarian government policy was first to push them back, then let some through and then to build a fence to stop more from coming.
The government says its migration policy is the only consistent policy in Europe: to secure its borders and to expel illegal immigrants.
"For us migration is not a solution but a problem ... Not a medicine but a poison. We don't need it and we won't swallow it," Mr Orban said earlier this year.
"Every single migrant poses a public security and terror risk," he said.
The government's campaign to ensure a "no" vote cost close to £30m.
Government posters and billboards displayed access the country said: "Don't risk it - vote no".