The European Court of Human Rights ruled on Tuesday that states belonging to the Council of Europe can control the entry of foreign nationals, including when migration is being weaponized. It also said states must protect migrants from inhumane or degrading treatment.

The ruling concerns the entry of nationals of Afghanistan, Iraq and Cuba into Poland, Latvia and Lithuania between 2021 and 2022. At the time, Belarus and the EU’s eastern member states were involved in a border standoff. Belarus was accused of manufacturing a migration crisis to pressure the EU, arranging for people from various third countries to enter Belarus and directing them to the EU’s borders.

The court described Belarus’ actions in 2021 as an instance of “instrumentalization of migration.” It said that, even during a surge in migration, national authorities must identify people particularly at risk of suffering or ill treatment.

The migrants in the case said they were violently prevented from crossing into the EU, their asylum applications were not examined, and their human rights were violated. The court’s press release said: “In a context of instrumentalization of migration, the removal of a foreign national to the instrumentalizing state would not, as such, constitute a violation of Article 3 (prohibition of torture and inhuman and degrading treatment).”

The court ordered Poland, Latvia and Lithuania to pay compensation for their treatment of migrants at the EU’s external borders with Belarus.

The Council of Europe has 46 member states, including all EU countries and some non-EU countries, and promotes democracy and human rights on the continent. The ruling comes as five EU countries announced a plan last week with Rwanda to establish a so-called return hub for rejected asylum seekers waiting to return to their countries of origin. The project has drawn concerns because Rwanda ranks low on human rights measures and there are questions about whether people’s rights will be sufficiently protected.