Refugees walk along railroad tracks at the Hungary-Serbia border, near the town of Horgos on September 14, 2015 | ARMEND NIMANI/AFP/Getty Wait, the Serbs are now the good guys? As Hungary and Croatia close their borders, tens of thousands of migrants are now trapped in Serbia.

BELGRADE — Hungary’s decision to seal its southern border has turned the spotlight of the migrant crisis onto Serbia, where images of columns of refugees fleeing conflict evoke all-too-recent memories.

Only a decade-and-a-half ago, Serbia was an international pariah, shunned for its role in the Yugoslav wars, and perceived as the instigator of ethnic conflict and persecution. Now government and civil society have won praise for the compassion with which the current crisis has been handled. The government has wasted no time in drawing a contrast between EU member Hungary tear-gassing migrants — on Serbian soil — and its own approach.

“The consensus is that Serbia has dealt with it very well so far in the circumstances, and that migrants are treated with great respect and dignity,” said a diplomat from an EU member state.

But with no signs of the flows slowing, and EU members to the north and west pulling up the drawbridge, the institutional and social capacity of one of Europe’s poorest countries to cope is limited. Until now Serbia has made almost no provision for migrants to stay, calculating correctly that the vast majority of refugees are just passing though on their way to Germany, Scandinavia and Belgium. The average stay is currently three days.

Until now, the country has largely "pumped" migrants north to the EU, which has not put unbearable strain on Serbia's financial and emotional resources.

That may change.

Around 160,000 migrants have passed through Serbia since the beginning of the year. An estimated 2,000 to 4,000 are arriving every day, mostly via Preševo on the southern border with Macedonia. After clashes on the fenced-off Serbian border with Hungary on Wednesday, migrants have turned towards Croatia, with 7,000 entering in the last day.

Croatia’s own response has been equivocal, at first saying it would allow free passage towards Northern Europe, but a day later saying that it would “not be able to receive more people.” It has now closed seven of its eight border crossings with Serbia. This raises the prospect of tens of thousands of people becoming trapped in Serbia.

So far, Serbia has generally followed a policy of free passage, including busing migrants, and offering limited accommodation, healthcare and legal support at transit centers.

People are donating clothes and food, and migrants sleeping in tents outside Belgrade’s scruffy bus station are left untouched. Local and international non-governmental organizations have been active in providing help, including at the Hungarian border at Horgos, where a support camp was being packed up on Thursday as migrants drifted westward, some on foot, some on official buses.

Following the use of water cannon, pepper spray, and tear gas on migrants, including children, by Hungarian police, Serbian Prime Minister Aleksandar Vučić was swift to condemn Budapest's “non-European” behavior, saying: “I call on the European Union to react, for its members to behave in line with European values.”

The difference in tone between Vučić, once an ultranationalist, and Hungarian Prime Minister Viktor Orbán, once a pro-Western liberal, has not gone unnoticed.

“The feeling amongst foreign ambassadors is that Serbia is displaying European values that some would say some EU member states are not displaying. This does Serbia’s EU aspirations no harm,” said the EU diplomat.

An EU representative in Serbia said that the country was being showered with praise by Brussels for its approach, and added that he hoped that Serbia’s stance was a sign that the country was becoming a “normal, fully-fledged” European country after many difficult years of transition. Serbia is a candidate to eventually join the EU.

Coordination between government, NGOs and individuals — often at cross-purposes on a day-to-day basis — has been impressive. The relatively high level of sympathy for the migrants is partly due to the recent memory of the Yugoslav wars, which displaced millions. Serbia is home to many Serbs who fled Bosnia, Croatia and Kosovo between 1991 and 1999, as well as many of various nationalities from around the former Yugoslavia who have come to Serbia seeking a better life.

“There is a sentiment of solidarity with the refugees, some people recognize their own past in what is happening,” said Dušan Janjić, a Serbian sociologist and an expert on extremism. “The ex-radical Vučić reacted very well.”

Nonetheless, there are real concerns about what will happen if the EU becomes a fortress and leaves Serbia to deal with the consequences. Foreign Minister Ivica Dačić has warned the EU not to treat the country as a “collection center.”

Now that Croatia is also locking down its border, Serbia is likely to face pressure both on its physical and administrative capacity to manage the situation, and the so-far positive attitude to the migrants passing through on their way to the EU's open-border Schengen Zone.

Serbia is paying the price of EU inaction — James Ker-Lindsay

Having run Europe’s largest budget deficit last year, and with GDP per capita below not just the European but the global average, Serbia has extremely limited resources. The EU representative said the bloc is ready to help Serbian authorities come up with a list of what they need. They are already working on developing transit camps, but Serbia can’t fix the problem alone. With a Balkan winter in the offing, better shelter will become a priority.

“The emphasis from our perspective is that Serbia is doing a good job in circumstances but clearly can’t be expected to shoulder the burden of all this; it physically can’t,” said the diplomat.

Ironically, Serbia’s limited and heavily pro-government media, normally a subject of EU criticism, has helped maintain the pro-refugee feeling among ordinary Serbs. This sentiment may start to fray if the numbers of migrants increase.

While Serbia has a significant Slavic and Albanian Muslim population, it has little modern history of mass migration from outside Europe, and xenophobia is far from extinct. Unemployment runs at around 25 percent, and there has been no public debate about how to replace the 40,000 Serbian citizens who emigrate every year.

Moreover, Serbia, as an EU candidate state, may feel reluctant to bear the burden in the name of solidarity while far richer full members continue to stonewall.

“Serbia is paying the price of EU inaction,” said James Ker-Lindsay, a Balkan expert at the London School of Economics. “The situation is completely out of their hands. One wonders if this could lead to a backlash against the EU. They can’t deal with it, so they dump it on us.”