The EU said Thursday that Hungary's building of a fence to keep out migrants was not an effective way of halting the tide of humanity washing up on Europe's borders.
Hungary said Wednesday it would build a four-metre (13-foot) high fence on its border with Serbia, arguing that other countries such as Spain and Greece had taken similar measures and it was not breaking any international law by doing so.
Asked about the announcement, European Commission spokeswoman Natasha Bertaud said "member states have the responsibility to manage their own borders ... however any measure has to be fully in line with EU laws and international obligations."
Among those, was the international obligation accepted by the European Union that those migrants seeking asylum should not be turned back, Bertaud said.
"More generally, the Commission does not promote the use of fences. We have only recently taken down fences in Europe and we should not be putting them up again," she said.
Member states should look at alternatives, she added, without giving details.
Right-wing Premier Viktor Orban, who has a record of spats with Brussels, has been among the harshest critics of EU plans to manage the upsurge in migrant numbers by spreading the burden around the 28-nation bloc.
On Wednesday, Budapest said it had ordered work to start along the length of its 175-kilometre (110-mile) border with non-EU member Serbia.
Hungary is in the EU's passport-free Schengen zone which means that once migrants are inside the country, they can travel freely elsewhere.
Last year, Hungary took in more refugees per capita than any other EU country apart from Sweden, recording 43,000 arrivals in total.
So far this year some 54,000 refugees have entered Hungary, most of them via Serbia, according to government figures.
Spokeswoman Bertaud said the Commission "has made it very clear that when it comes to migration there are no national solutions only EU ones."
In the case of Italy and Greece, which have borne the brunt of the last migrant influx, the Commission has suggested asylum seekers could be relocated to other EU countries to share the burden and similar measures could be proposed to help other member states, she noted.
On Tuesday, EU interior ministers failed to agree on Commission proposals to redistribute 40,000 Syrians and Eritreans who have arrived in Europe, and to resettle 20,000 Syrians living in camps outside Europe.