Police can now detain anyone who tries to breach a razor-wire fence built on the border with Serbia.
The EU is facing a huge influx of migrants, many fleeing conflict and poverty in countries including Syria and trying to reach Western Europe.
A boat carrying migrants from Turkey to Greece sank on Tuesday, leaving 22 people including four children dead, Turkish media reported.
Starting on Tuesday, the EU has agreed to relocate 40,000 migrants from Greece and Italy to other EU states. But it has yet to agree on mandatory quotas for a further 120,000 asylum seekers.
The new Hungarian laws came into effect at midnight (22:00 GMT Monday).
Police sealed a railway crossing point that had been used by tens of thousands of migrants, and many slept out in the open on the Serbian side of the border.
Police buses will now take asylum applicants to registration centres, but if their applications are refused they will now be returned to Serbia rather than being given passage through Hungary, the BBC’s Nick Thorpe reports from the border.
Hungarian authorities said more than 9,000 – a new record – crossed into the country before the border was closed on Monday, and that the total number arriving this year had risen above 200,000.
From Tuesday, anyone who crosses the border illegally will face criminal charges, and 30 judges have been put on standby to try potential offenders.
The laws also make it a criminal offence – punishable by prison or deportation – to damage the newly-built four-metre (13ft) fence along Hungary’s 175km (110 mile) border with Serbia.
Mounted police have been deployed along the border.