For the second time this year, a Minneapolis-based federal judge has ordered the release of an Iraqi native with permanent U.S. residency who is being held indefinitely in a Minnesota jail.

U.S. District Judge David S. Doty on Tuesday wrote that Farass Adnan Ali was has been in pre-deportation detention consecutively since July 2017. "This is a significant period of detention based entirely on the attorney general's exercise of discretionary authority," Doty wrote, adding, "This factor strongly favors granting relief."

In addition, after two years of immigration proceedings, the Department of Justice's Board of Immigration Appeals can't say when Ali could be deported. "Simply put, there appears to be no end in sight for Ali's removal proceeding," Doty wrote. "This factor also favors granting relief."

Ali came to the United States as a refugee in 2014 and received lawful permanent resident status. But federal officials moved him into detention because they say he didn't disclose his service in the Iraqi Republican Guard on his application. Even if he were released from jail, Ali would still face deportation proceedings.

In the meantime, also favoring release of Ali, Doty wrote, is that he's in the Sherburne County jail in Elk River under conditions "indistinguishable from penal confinement," Doty wrote. The jail houses state criminal inmates as well as federal detainees.

Ultimately, Doty wrote that Ali's eventual deportation to Iraq is "questionable" given the "tenuous diplomatic relations" with that country and the United States.

Doty didn't give weight to government claims that Ali would be a security threat if released. Ali has not been designated a terrorist or a criminal, Doty wrote, adding again that his detention is merely based on the discretion of the U.S. Attorney General.

He said the government can place restrictions on Ali's release, but must free him within 30 days. The government, however, can appeal Doty's ruling.

The ACLU-MN's Greater Minnesota Racial Justice Project has taken on Ali's case. "This is a clear case of government overreach in detaining people who have no significant criminal record for months or even years," ACLU lawyer Ian Bratlie said. "The government is clearly sensationalizing this case in its quest to demonize immigrants."

Doty ordered Ali's release in January and the government appealed to the 8th U.S. Circuit Court of Appeals. The appeals court reversed that decision and told Doty to further consider Ali's constitutional claims. Now Doty has done that and again ordered his release.

The veteran judge was appointed by President Ronald Reagan in 1987.

A spokeswoman for ICE didn't immediately respond to a request for comment.