It is a tiny group by any standards, but a few dozen Afghans stranded in no-man’s land between the Belarusian and Polish borders are causing Poland’s government some serious difficulties.

Prime Minister Mateusz Morawiecki and his administration have pledged to protect “holy Polish territory” by keeping the migrants kettled in a small space at the border zone with Belarus, even as it has sent aircraft to rescue more than 1,000 Afghans who helped its troops and diplomats during the past 20 years. The administration has meanwhile delayed a decision on a U.S. request to accept another 3,000 Afghans.

The inconsistencies result from Polish politics. With early elections possible next year, the leader of the opposition Civic Platform party, Donald Tusk, drily described border migrants as “political gold” for Morawiecki’s ostensibly anti-immigration party.

While the PiS has in fact overseen a huge influx of migrants, nearly all — more than a million — are Ukrainians, who have generally been welcomed by Poles. The controversy relates to those from the developing world. Morawiecki has accepted that Poland needs migrant labor, given a serious demographic crunch, but has made plain that some are more welcome than others.

Ministers also point out that the Belarusian dictatorship of President Aliaksandr Lukashenka is seeking to punish neighboring European Union (EU) states by sending them developing world refugees. Over the past months, record numbers of migrants have crossed from Belarus into the European Union through Poland, Latvia, and Lithuania. Numbers have risen steeply over the summer. The Morawiecki government has responded with pledges to build a fence and has doubled the number of troops in the area. On August 31, it sought a state of emergency in two eastern regions of the country bordering Belarus.

The migrants sitting inside the Belarusian border, sandwiched between Polish and Belarusian troops near the village of Usnarz Gorny. Journalists have not been allowed within 200 meters, and the migrants are confined to a space of 30 square meters. The European Court of Human Rights (ECHR) has ordered Poland to provide aid, including food, water, clothing, medical care and shelter, but stated that neither country was obliged to allow the refugees to enter their territory.

Meanwhile, Poland has accepted that it owes a debt to Afghans who assisted its lengthy effort in Afghanistan and has offered refuge. The country operated 44 flights and airlifted 937 Afghan citizens. Poland also promised to help evacuate 500 Afghan citizens who had assisted with the NATO mission in Afghanistan.

A fortnight ago, reports said that the United States asked Poland to take in approximately 3,000 Afghan refugees, many of whom were connected to the U.S. mission. The Polish government did confirm talks were underway, but spokespeople stressed that the focus was on evacuating those who had assisted the Polish mission. Dworczyk said that “dialogue with our American partners” was underway, but there were no conclusions or promises. Various Polish cities have signaled willingness to host Afghan refugees, including the mayor of Sopot.

The current debate is the latest iteration of a fierce debate across central Europe about developing world refugees, something that has also played out in a lengthy dispute between the PiS government and the EU. The PiS was fiercely opposed to EU quotas during the surges of Syrian migrants in 2014–16. Then, as now, the Polish government was reluctant to accept migrants, especially from the Middle East, citing security concerns and — less loudly — noting the problems of West European countries with Islamist terrorism and societal alienation.

The border zone, previously nondescript strips of land and forest with no discernible markings, is now being lined with barbed wire. There is talk of a Polish “wall”, not unlike Viktor Orbán’s at the Hungary-Serbia border. Poland is not alone: fences are now being constructed across central and eastern Europe, in places like Greece and Bulgaria, to bar developing world immigrants.

The rest of the EU is in an impossible position, and is anyway extremely worried by the prospect of another massive and uncoordinated influx of migrants like 2015 which could again destabilize continental politics.

But the scenes of Poland’s eastern border provoke deep misgivings among many Poles and other Europeans. These are human lives and it seems odd to make an example of one group while welcoming another of the same nationality, leaving them in limbo for weeks at the border while hoping the country that put them there — Belarus, with its established disregard for the human rights of its own citizens, let alone migrants’ — will cave.

Poland, and the EU, need a plan.