NEW YORK — Hanad Abdi fled Somalia two summers ago after men killed his father and stole the family farm. His only hope for safety and freedom, he said, was to flee to America.

But after smuggling himself to Ethiopia, then Brazil, then thousands of miles through South and Central America, he landed in an immigration detention center in snowy Batavia, New York, where he was held for 10 months while he applied for asylum.

“I came to get help. I didn’t come to go to jail,” Abdi said in a phone interview from Minneapolis, where he has been staying with relatives since his release in August. “I wasn’t a criminal.”

A federal judge in Rochester heard arguments Friday in a lawsuit brought by the New York Civil Liberties Union and the International Refugee Assistance Project on behalf of more than 30 men, including Abdi, who were held for extended periods at the detention facility in Batavia.

The civil liberties 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 to asylum seekers began declining during the Obama administration and all but ended in the Trump administration.

“The harsh truth is that asylum seekers who have fled danger in their home countries are left to languish in American detention without any real opportunity for release,” said Mariko Hirose, litigation director at the refugee assistance project.

A spokesman for the U.S. Immigration and Customs Enforcement in New York declined to comment on pending litigation. The Department of Justice had no comment.

The United States granted asylum to 26,124 people in 2015, the most recent figures available. 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 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.

President Donald Trump 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.”

The facility in Batavia, about 350 miles north of New York City 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.

Similar situations are playing out at detention facilities nationwide, according to a report by Human Rights First, a nonprofit human rights organization. For example, out of 25 asylum seekers represented by the National Immigrant Justice Center at facilities in the Midwest, no one has been granted parole since the inauguration.

“What all the evidence makes clear is that parole largely stopped right after President Trump’s inauguration and only resumed when we went to court,” said Christopher Dunn, legal director for the NYCLU.

Johan Barrios Ramos wound up in the Batavia detention center after fleeing Cuba on a raft in January. He said he had been detained and tortured in a Cuban prison for 11 months in 2013 because of his involvement with the political opposition. He was in detention in Batavia for almost as long — eight months — before his release. He is now living in Miami while his asylum application is pending.

“I never thought I’d be treated like this,” Ramos said in Spanish.