Migrants walk on a road toward the crossing point between Hungary and Austria in Nickelsdorf on September 12, 2015.Leonhard Foeger / Reuters

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.

Austria and Slovenia appealed to the court, urging it to reinstate the Dublin rules. On Wednesday, the court did just that. The ECJ ruled the Afghan families and the Syrian should have sought asylum in Croatia, noting one EU member’s decision to suspend the Dublin rules—in this case Germany—did not mean that the suspension stood for other EU members. Hundreds of migrants are likely to be affected.

“For those already in Croatia, 700 or so, for them the story is over,” Clemens Lahner, an Austrian lawyer, told the BBC. “Austria won’t take them back.”

In a related case, the ECJ’s advocate general, Yves Bot, recommended that the court dismiss a lawsuit brought by Hungary and Slovakia challenging the EU’s migrant quota for its members—a distribution the bloc mandated following the impact the flow of migrants was having on Greece and Italy, where many migrants first arrived after crossing the Mediterranean. A decision in the case is expected later this year. The ECJ is not required to follow its top adviser’s recommendation, but it typically does.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.