Hungarian Prime Minister Viktor Orban said there is a clear link between illegal migrants heading to Europe and a rising threat of terrorism, justifying his conservative government's tough anti-immigration stance and its erection of a four-metre-high fence along its border with Serbia.

The landlocked central European country is part of Europe's visa-free Schengen zone, making it attractive to migrants coming through the Balkans. It has registered more than 80,000 migrants so far this year, nearly double the number in all of 2014.

Most are from poor or conflict-ridden countries like Syria, Afghanistan and Iraq, looking to move on to wealthier western Europe.

Hungary plans to complete a four-metre-high fence along its border with southern neighbour Serbia by November to stem the flow of migrants. The plan has drawn criticism from Serbia as well as the United Nations' refugee agency.

"There is a clear link between illegal migrants coming to Europe and the spread of terrorism," Orban said in an annual speech in Romania, where he usually outlines his political vision for the coming years.

"It is obvious that we simply cannot filter out hostile terrorists from this enormous crowd."

The issue of migration has become highly politicised in Hungary, with Orban's government mounting a billboard campaign telling migrants to respect Hungary's laws and stoking fears that foreigners could snatch the jobs of Hungarians.

"Our answer is clear: we would like to preserve Europe for Europeans ... and this also requires an effort from other (countries)," Orban said. "But there is something that we would not only like but we want: to preserve Hungary for Hungarians."

Illegal immigration had contributed to a rise in unemployment and crime in Western countries, he said.

Hungary's parliament has passed legislation, defying UN criticism, to shorten the time for screening asylum claims and to reject applications from migrants who have passed through third countries it considers safe without seeking asylum there.

Orban, whose Fidesz party is losing ground to Hungary's far-right, eurosceptic, anti-immigrant Jobbik party, said the "human rights fundamentalism" of the West provided moral encouragement to migrants.

European Union policies were not robust enough to defend its own citizens from the threats posed by rising immigration, he said.

Hungary is part of Europe's visa-free Schengen zone, making it attractive to migrants coming through the Balkans. It has registered more than 80,000 so far this year, compared with 43,000 in all 2014. Most are from poor or conflict-ridden countries like Syria, Afghanistan and Iraq.

The number trying to reach western Europe through Hungary could reach 200,000 to 300,000 this year, Antal Rogan, the parliamentary group leader of the ruling Fidesz party, told the newspaper Magyar Hirlap in an interview published on July 24.

Construction of the 175 km fence, which has drawn rebukes from Serbia and the United Nations Refugee Agency, started earlier this month.

The fence could reduce the ranks of incoming migrants to a seventh of current levels, Rogan has said, pointing to other examples, such as a fence along the US border with Mexico, and some European countries, such as Bulgaria, which have raised physical barriers of their own.

Shelters in Hungary and Austria are overcrowded, and late last month Hungarian police used tear gas to subdue hundreds of migrants fighting each other and throwing rocks in a camp in the eastern town of Debrecen.