The European Court of Justice (ECJ), the bloc’s apex court, ruled Wednesday that migrants must seek asylum in the first country they reach, a ruling that could have far-reaching consequences for many of those who arrived in 2015 and 2016 during Europe’s most-severe refugee crisis since World War II.

The case involved Khadija and Zainab Jafari, two sisters from Afghanistan, and their children. They entered Austria in February 2016 after entering the EU in Croatia. The families applied for asylum in Austria—a request that was ultimately declined. Austrian authorities ruled they should be deported to Croatia, their first point of entry in the EU. The case, along with one of a Syrian man, was taken to the ECJ.

At issue is the so-called Dublin rule, the EU procedure that mandated that migrants seek asylum in the country where they first arrive. But at the height of the Syrian civil war, Germany suspended the rule, saying it had adopted an open-door policy for Syrian refugees. The announcement led to a massive flow of migrants from Syria and elsewhere who often undertook risky journeys to make their way to Europe and, ultimately, Germany. But that flow of refugees created a massive bottleneck in the rest of Europe—and severe social and economic costs in many member states. About 90,000 migrants—1 percent of Austria’s population—sought asylum in the country. Slovenia, meanwhile, became transit ground for people entering Austria. About 500,000 people entered the country, which has a population of 2 million.