The majority of people voting in Hungary's referendum have rejected mandatory EU quotas for relocating migrants, but a low turnout to vote could invalidate the result.

Despite the largest advertising campaign in Hungary's history, more than half of the electorate have apparently stayed away from the ballot which, if finalised, would mean the process would be constitutionally null and void.

Voters were asked: "Do you want the European Union to be able to mandate the obligatory resettlement of non-Hungarian citizens into Hungary even without the approval of the National Assembly?"

Around 98% of those who voted supported the government's position but only 43% of the electorate voted, short of the 50% required to be valid.

The government has insisted the ballot was binding "politically and legally" but the opposition said the government did not have the required support.

Leader of the opposition Democratic Coalition, Ferenc Gyurcsany said according to the BBC: "According to this result with such low turnout, the people do not support the government. And this is good. The migration issue outreaches Hungarian borders."

The referendum was spearheaded by prime minister Victor Orban, who opposed plans to relocate 160,000 migrants across the EU under a scheme in which Hungary would get 1,294 asylum seekers.

Hungary was under fire from human rights groups when it sealed its borders with Serbia and Croatia and became part of the transit route from the Middle East to the EU.

Lazslo Robi, from the Budapest-based think tank Political Capital Institute, told the Guardian that even if most people who voted had agreed to rejecting the EU quotas, it would be seen as a failure.

"It's a tricky situation because at least three million people voted – and this amount of people could be regarded a huge success," said Robi. "But now this could also be regarded as a huge failure, because Orbán set the bar much higher.

"He'll still say that the Hungarian nation is behind him, but Brussels will be able to say: you didn't hold a valid referendum."