BOSTON (Reuters) - A lawsuit attempting to block the Trump administration from arresting illegal immigrants seeking to legalize their status based on their marriages to U.S. citizens can move forward, a federal judge in Boston ruled on Thursday.

U.S. District Judge Mark Wolf said the American Civil Liberties Union can proceed with the lawsuit, which accuses the government of unlawfully separating certain illegal immigrants from their families as they sought lawful residency.

The lawsuit centers on regulations the U.S. Citizenship and Immigration Services (USCIS) enacted in 2016 during former Democratic President Barack Obama’s administration that allowed certain non-citizens, who were married to U.S. citizens, to remain in the country while they applied for legal residency.

The ACLU’s lawsuit said the U.S. Immigration and Customs Enforcement (ICE) under President Donald Trump was detaining people seeking to benefit from those regulations when they went to government offices as part of the legalization process.

The Republican president’s administration has taken a hard line on restricting immigration.

The ACLU has said records show that USCIS officials in New England collaborated with ICE agents to arrest immigrants when they came in for interviews.

The civil rights group said that amounted to a “trap” that violated the rights of illegal immigrants who were following regulations designed to help them to become lawful residents.

Wolf on Thursday rejected the Justice Department’s claim that he lacked jurisdiction under federal law to hear any lawsuit challenging the authority of the U.S. Department of Homeland Security, which ICE forms part of, to enforce a removal order against an immigrant.

Wolf said the lawsuit plausibly alleged that ICE failed to consider whether immigrants were seeking an exemption under the 2016 regulations before detaining them.

“ICE may not order the removal of an alien pursuing a provisional waiver merely on the basis of finding the alien is subject to a final order of removal,” Wolf said in court.

ICE declined to comment, citing the pending nature of the lawsuit, which seeks class action status.

The class action claims in the lawsuit were added to an earlier case centered on Lilian Calderon, a Guatemalan immigrant who was arrested at a government office in Rhode Island in January after an interview that was part of the process to seek legal status.

Calderon, who is married to a U.S. citizen and has two children, was detained for about a month and was only released after the lawsuit was filed.