The Hungarian parliament has passed new legislation that criminalises lawyers and activists who help asylum seekers.
Anyone "facilitating illegal immigration" will face a year in jail.
Viktor Orban's government has dubbed the legislation the "Stop Soros law", after the billionaire philanthropist it accuses of supporting Muslim migrants.
The vote in Budapest came hours after a number of European Union leaders agreed to hold crisis talks on how to overhaul asylum rules.
Hungary says immigration threatens its national security, but its hardline stance and new law have faced widespread international criticism.
The UN refugee agency urged Hungarian officials to scrap the proposed law and legal experts from the Council of Europe human rights organisation appealed for the vote to be postponed until they had submitted a review of the measures on Friday.
A report by the Council's Venice Commission leaked to the BBC said the Hungarian legislation "criminalises organisational activities which are not directly related to the materialisation of the illegal migration".
Why is the law controversial?
The new legislation amends eight existing laws and introduces one new crime of "facilitating illegal immigration".
Under the new law, anyone could be jailed for working for or with non-governmental organisations that are involved in helping or campaigning for asylum seekers. Human rights groups insist all they are trying to do is help people who have been allowed in Hungary legally apply for asylum.
The measures also tighten restrictions on asylum, so that anyone attempting to enter Hungary from a third country where they are not directly threatened with persecution cannot claim protection.
In a related development, MPs passed an amendment to the constitution that declares that "alien populations cannot be settled in Hungary", in effect outlawing the European Commission's attempts to relocate asylum seekers from Italy and Greece to other EU states.
When some 400,000 people travelled through Hungary in the middle of the migrant crisis of 2015 on their way to Western Europe, Mr Orban ordered fences put up to halt the influx. The Commission imposed a mandatory asylum quota for every EU state in response to the crisis, but Mr Orban refused to accept it.
In 2015, 177,000 people sought asylum in Hungary but only a few hundred were accepted. Last year, the number of asylum claims fell to around 3,200.