After nearly two months in an immigration detention facility, Pablo Villavicencio is getting a slice of freedom.

A federal judge on Tuesday ordered the release of an Ecuadorean man detained by immigration officials while delivering a pizza to a military base in New York City, even as he continues to fight to change his legal status.

U.S. District Judge Paul Crotty issued an order Tuesday evening calling for the immediate release of Villavicencio, a father of two and pizza deliveryman who was living in the United States illegally but has filed to change his immigration status. The judge also ordered a stay of deportation for Villavicencio as he fights to gain legal status.

In this undated family photo provided by Sandra Chica, Pablo Villavicencio poses with his two daughters, Luciana, left, and Antonia. AP

Villavicencio must be released immediately from custody because his removal from the country was “no longer reasonably foreseeable,” the judge ruled in an order that was to be followed by a formal opinion.

In his order, the judge said that aside from his immigration status, Villavicencio has “otherwise been a model citizen” and has no criminal history and has paid taxes, and has a wife and two young daughters who are all U.S. citizens.

Villavicencio’s attorneys, from The Legal Aid Society of New York and Debevoise & Plimpton LLP, issued a statement Tuesday evening commending the judge’s ruling.

“The rule of law, humanity and morality prevailed tonight with the Court’s order releasing Pablo back to his family and community,” Adriene Holder, attorney-in-charge of civil practice at The Legal Aid Society, said in the statement. “This decision should serve as a rebuke against the Trump Administration and its merciless crusade to tear families apart.”

“The Villavicencio family has finally received a crucial measure of relief from their 53-day nightmare and we will continue to fight alongside them to protect their right to remain in the community they call home,” she added.

Villavicencio had been held in Immigration and Customs Enforcement custody in New Jersey. His case drew national attention and spurred protests after he was arrested in June at an Army base in Brooklyn while delivering pizza from a restaurant in Queens.

He used a municipal identification card that is free for New York City residents and does not require a person to be authorized to live in the U.S. His family and advocates helping his case have said that while that identification worked during previous deliveries, on June 1 it did not and when officials ran a background check they discovered an order of deportation for Villavicencio from 2010 and arrested him.

Villavicencio entered the country illegally in 2008 and had not left the country despite the 2010 order of deportation. In 2013, he married Sandra Chica, a U.S. citizen and has two young daughters. Through his wife’s citizenship status, he applied to change his immigration status and obtain permanent legal residency in February, but that case has yet to be decided.

Another judge had also previously blocked Villavicencio’s deportation.

Earlier Tuesday, Crotty questioned why Villavicencio had been detained for more than 50 days following his arrest.

"Why is he being detained? Is he a threat to the community? Is he a risk of flight?" Crotty asked, according to NBC New York. "What is the danger to the community for a man who has committed no crime?"

He added, "I mean, is there any concept of justice here or are we just doing this because we want to?"