Hungary has brought in tough new migrant laws which it says will “start a new era” in preventing the inflow of illegal immigrants.
Police can now detain anyone who tries to breach a razor-wire fence built on the border with Serbia.
Hungary has become a key point on the journey north for thousands of migrants from the Middle East and Africa.
On Monday, EU ministers failed to agree unanimously on mandatory quotas to relocate 120,000 asylum seekers.
Instead, at the meeting in Brussels, a majority agreed “in principle” and negotiations will now take place ahead of another meeting in October.
The new Hungarian laws came into effect at midnight (22:00 GMT Monday).
From now on 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.
Police also sealed a railway crossing point that had been used by tens of thousands of migrants to enter the EU.
“We will start a new era,” government spokesman Zoltan Kovacs said shortly after midnight. “We will stop the inflow of illegal migrants over our green borders.”
But he added: “That also means that the official and legal ways to come to Hungary and therefore to the European Union remain open. That’s all we ask from all migrants – that they should comply with international and European law.”
At the Brussels talks, Luxembourg, which holds the EU presidency, said it was hoped that the relocation proposal could be made law at a meeting on 8 October.
The Czech Republic, Slovakia and Hungary were reportedly among the nations opposed to mandatory quotas.
“There was no consensus, several countries disagreed,” Slovak Interior Minister Robert Kalinak said after the talks.
Luxembourg Foreign Minister Jean Asselborn said “not everyone is on board at the moment”.
He warned the situation in Europe was “urgent and dramatic and time is of the essence”.
Ministers did, however, agree to begin the relocation of 40,000 migrants from Greece and Italy to other EU states, as proposed by the European Commission before the summer.
Under complex EU rules, a unanimous vote is not required and decisions can be made with a qualified majority.
However, correspondents say that would be a show of disunity that the EU is trying to avoid.
Mr Asselborn said a list of safe countries, to which failed asylum seekers can be returned, had been agreed on principle.
European states have been struggling to cope with a record influx of migrants, who are mainly trying to reach Germany and Sweden.
On Monday, a number of European countries followed Germany’s suit in introducing temporary border checks.
The moves are a challenge to the EU’s Schengen agreement on free movement, although the rules do allow for temporary controls in emergencies.
Austrian police said up to 7,000 people had arrived from Hungary on Monday, and 14,000 on Sunday.
Chancellor Werner Faymann said troops were also being deployed, mainly to provide humanitarian help within Austria, but would be sent to the border if necessary.