Budapest (AFP) - Hungary's parliament gave Monday the army and police sweeping new powers to keep migrants out as populist Prime Minister Viktor Orban warned that Europe was being "overrun".

"They are overrunning us. They're not just banging on the door, they're breaking the door down on top of us," the right-wing Orban told lawmakers.

"Our borders are in danger, our way of life built on respect for the law, Hungary and the whole of Europe is in danger," the 52-year-old said in Budapest.

"Europe hasn't just left its doors open but has sent open invitation... Europe is rich but weak, this is the worst combination, Europe needs to be stronger to defend its borders."

The new legislation, passed with a two-thirds majority, allows the army to take part in border controls, to restrict personal liberties and to use "coercive weapons designed to cause bodily harm, although in a non-lethal way, unless it cannot be avoided."

"Similar to the police, the use of non-lethal firearms, rubber bullets, pyrotechnics, tear gas grenades, and net guns can be used," it stipulates.

Coming a week after illegal border-crossing became a crime punishable by up to five years in jail, soldiers can now also check ID papers and detain suspected illegal migrants.

The police meanwhile will be able to enter private homes for the purpose of carrying out a search for migrants who entered the country illegally, amongst other new powers.

The rules are applicable in areas where a "state of crisis caused by mass immigration" has been declared. Last week the government declared such a state in six counties bordering Serbia, Croatia, Slovenia and Austria.

The Hungarian Helsinki Committee, a refugee rights group, warned that refugees should not be treated as enemies.

"The extended powers of the army and police must be used with utmost care in situations involving refugees who themselves have fled from war and terror and have already suffered gravely from police and armies in their home countries," said the group's chief Marta Pardavi.

Story continues

- Sealing borders -

EU member Hungary has emerged this year as a frontline state in Europe's migrant crisis, with 225,000 travelling up from Greece through the western Balkans and entering the country from Serbia and most recently Croatia.

Most then enter Austria which lets them travel onwards to Germany.

Last week Hungary sealed its southern border with Serbia, forcing tens of thousands of migrants to enter Croatia, from where many then again crossed into Hungary and headed for Austria and beyond.

The country has erected a razor-wire barrier along its 175-kilometre (110-mile) border with Serbia and along 40 kilometres of its border with Croatia not marked by the Drava river.

It is also building a four-metre high fence along its border with Serbia and is planning to erect a barrier along its frontier with Romania too.

Hungary has been widely criticised for its treatment of the migrants, including in clashes last week when police used tear gas and water cannon against protesters throwing stones and other missiles.

Orban argues that Hungary is applying EU regulations and blames Greece for waving migrants through and Germany -- the migrants' main destinations -- for relaxing asylum rules for people fleeing Syria's civil war and Islamic State extremists.

He also rejects that the new arrivals are refugees, saying they are either "economic migrants" in search of a better life or Syrians who voluntarily left camps outside Syria where their lives are not in danger.