NEW YORK — A judge ruled that a federal detention facility in New York must reform how it decides parole for immigrants arriving to the United States who claim persecution in their homelands.

U.S. District Court Judge Elizabeth Wolford ruled Friday in a lawsuit brought by the New York Civil Liberties Union and the International Refugee Assistance Project on behalf of more than 30 asylum-seekers who were held for extended periods at the detention facility.

“People who came to the U.S. border seeking only refuge will no longer suffer indefinite confinement in New York’s largest immigration detention facility,” said Christopher Dunn, associate legal director of the New York Civil Liberties Union. “Asylum-seekers deserve, and will now get, the chance to be with loved ones while awaiting their asylum hearings.”

U.S. Immigrations and Customs Enforcement officials did not immediately comment on the ruling.

The plaintiffs’ lawyers say people who came to the U.S. seeking asylum were once routinely granted parole, meaning they could stay out of jail while their applications were considered. But they say the practice of awarding parole began declining during Barack Obama’s administration and all but ended under Donald Trump.

Trump, a Republican, signed an executive order shortly after his inauguration directing immigration officials to “end the abuse of parole and asylum provisions currently used to prevent the lawful removal of removable aliens.”

It said parole should be granted “only when an individual demonstrates urgent humanitarian reasons or a significant public benefit derived from such parole.”

Those seeking shelter from their home countries often just show up at the border and turn themselves in. They are detained and interviewed to determine whether they have a “credible fear” of persecution or torture in their home country because of their race, religion, nationality, membership in a particular social group or political opinion. They must fill out an application and then attend court hearings.

The process can take years. A 2009 directive by ICE said that if a person was found to have a “credible fear” of persecution and presented no danger to society, he or she could be let out of detention for humanitarian reasons. The United States granted asylum to 26,124 people in 2015, the most recent figures available.

Wolford ordered immigration officials to redo the process at Batavia immediately. Asylum-seekers must be notified of the possibility for parole in a language they can understand and be granted an interview with an immigration officer. They must be informed that they can seek appeals if parole is denied and must be provided an explanation of why they were not granted parole.

The ruling also ordered bond hearings for those detained at Batavia for six months or more.

The facility in Batavia, near the Canadian border, is typical of other detention centers around the country, civil rights lawyers said. In the first six months of this year, six prisoners were granted parole out of the 44 who requested it.

Lawyers say the ruling should prompt changes to immigration parole procedures nationwide.