The U.S. Department of Homeland Security (DHS) has been targeting U.S. citizens’ foreign spouses when they apply for legal immigration status. Earlier this month, a federal judge in Maryland put a halt to this practice.

For the past few years, couples attending interviews about their marriages sometimes faced a terrible surprise: DHS officers were waiting to arrest and deport the noncitizen spouse after the interview. The interview is a standard part of the application process. After the recent ruling, DHS cannot do this in Maryland.

In Sanchez v. McAleenan, U.S. District Court Judge George Hazel ordered DHS to stop arresting, detaining, or deporting certain noncitizens seeking green cards based on their marriages to U.S. citizens in Maryland.

DHS also must release noncitizens already in custody based on the challenged practice. The decision applies while the case continues before the court.

This case focuses on a central question: can DHS deny these spouses the opportunity to apply for lawful permanent resident status while in the United States?

The spouses covered in this decision were previously ordered deported. DHS has been seeking to arrest them before they can complete the first step in the legalization process.

The process of seeking immigration status based on marriage to a U.S. citizen or permanent resident is often complicated and lengthy. For people who did not enter the United States at a port of entry and who previously were ordered deported, it can be especially arduous.

They often must apply for a visa while outside the United States, through a system called consular processing, and seek a waiver which allows them to reenter despite having previously spent time in the United States without authorization. Before 2013, people generally had to remain outside of the United States for months or years while applying for this waiver.

Under the Obama administration, DHS started a new program to allow people to request the necessary waiver while still in the United States. The program was intended to minimize the time that families were separated during consular processing.

But now, DHS isn’t following through on the promise made to these families. Instead, it is using the program’s marriage interviews as an opportunity to locate individuals with prior removal orders and then arrest and deport them.

The problem is not limited to marriage interviews in Maryland. In addition to the Sanchez case that benefits a large group of people, other courts have also recognized that the practice is unfair and unlawful in individual cases.

Federal courts in New York, New Jersey, and Maryland have ordered DHS to release and/or halt the deportations of individuals arrested at or before marriage interviews. A class action on behalf of couples facing the same problem in New England is pending before the district court in Massachusetts.

The decision in Sanchez is an important step in ensuring DHS does not upend the protections put in place to keep families safe and together while they seek lawful immigration status.