BELGRADE, Serbia — Balkan countries and the European Union on Thursday criticized Hungary's plans to build a fence along the border with Serbia to stop the flow of migrants reaching the country.

Serbia's prime minister, Aleksandar Vucic, said he was "shocked and surprised" by the project that could isolate his country.

Vucic said "walls and fences" weren't a solution for the crisis that has seen tens of thousands of migrants from the Middle East and Africa crossing the western Balkans, trying to reach the European Union as they flee wars and poverty in their home countries.

Announcing the plans, Hungarian Foreign Minister Peter Szijjarto said Wednesday the 4-meter-high (13-foot-high) fence along the 175-kilometer (110-mile) southern border with Serbia wouldn't contravene any of Hungary's international legal obligations.

The plan leaves a bitter taste in Serbia whose leadership is keen to become part of the EU rather than isolated from it.

"We don't want to live in an Auschwitz," Vucic said, referring to a Nazi concentration camp during World War II.

He told state TV that Serbia mustn't be blamed for the refugee crisis, because it's only a transit country on the migrants' route from EU states like Greece and Bulgaria.

"We don't know what this is all about," Vucic said, adding that he will discuss the fence plan with Hungary and EU officials. "We are not guilty and all of a sudden a wall is to be built."

EU spokeswoman Natasha Bertaud said the bloc "does not promote the use of fences and encourages member states to use alternative measures."

"We have only recently taken down walls in Europe; we should not be putting them up," she said.

Hungary's right-wing government has been waging an anti-migrant campaign, claiming that Muslims are threatening Europe's Christians. Prime Minister Victor Orban has said "the face of the European civilization will never again be what it is now."

Hungarian government spokesman Zoltan Kovacs said the fence "is a necessary but likely insufficient step by the Hungarian government to put a stop to the flow, which is reaching Hungary through the southern border."

"Hungary is a front country and everything must be done to protect the Hungarian people and Hungary from this uncontrolled and uncontrollable flow of illegal migrants," Kovacs said.

What has become known as "the Western Balkans route" is seeing a dramatic increase in refugees and migrants, mostly from Syria, Afghanistan and Iraq. Some are registering for asylum in the Balkans when they get caught, others are heading onward.

So far this year, more than 53,000 people have requested asylum in Hungary, up from under 43,000 in 2014 and 2,150 in 2012. If they aren't detained in Hungary, most migrants take advantage of the EU's open borders and head to richer European states like Austria, Germany, Switzerland or the Scandinavian states.

More than 22,000 asylum claims were filed in Serbia in the first five months of this year, a six-fold increase from the same period as last year. Close to 10,000 new asylum-seekers were registered by the authorities in May alone.

Nikola Kovacevic, from the Belgrade Center for Human Rights, which has been helping the refugees, said Hungary's decision won't stop the migrant flow.

"No wall has ever stopped migrations. They are unstoppable," Kovacevic told The Associated Press. "It will only make things harder for those people who need help and not more hardship."

Associated Press writers Jovana Gec in Belgrade, Raf Casert in Brussels, and Pablo Gorondi in Budapest, Hungary, contributed to this report.