[What you need to know to start the day: Get New York Today in your inbox.]

Adou Kouadio, a citizen of Ivory Coast, arrived at the Texas border in early 2016 and asked for asylum, claiming that he had been threatened after supporting a political opponent of his country’s president.

But for the nearly three years that his request has remained under consideration, Mr. Kouadio, 43, has been detained by the American authorities, first in Texas and later in New Jersey. In August, he petitioned a court for help.

On Thursday, a federal judge in Manhattan said the government had violated Mr. Kouadio’s rights.

“This nation prides itself on its humanity and openness with which it treats those who seek refuge at its gates,” the judge, Alvin K. Hellerstein of Federal District Court, wrote. “By contrast, the autocracies of the world have been marked by harsh regimes of exclusion and detention. Our notions of due process nourish the former spirit and brace us against the latter.”

Detaining Mr. Kouadio for 34 months without a bail hearing violated his due process rights as a nonresident immigrant arriving at the border, “limited as those rights are,” the judge said in a ruling some legal experts also considered a rebuke of the Trump administration’s strict immigration policies.