A federal judge has ordered the release of an Ecuadorian immigrant detained by Immigration and Customs Enforcement officials last month and held for deportation after he delivered a pizza to a U.S. Army installation in Brooklyn.

U.S. District Judge Paul Crotty ordered the release of Pablo Villavicencio, 35, from the Hudson County Correctional Facility in New Jersey. Villavicencio, who is married to a U.S. citizen, applied for a green card in February and is scheduled for an immigration interview next month.

Crotty granted a stay of deportation while Villavicencio awaits permanent residence.

"Although he stayed in the United States unlawfully and is currently subject to a final order of removal, he has otherwise been a model citizen," Crotty wrote in his order.

"He has no criminal history," the judge wrote. "He has paid his taxes. And he has worked diligently to provide for his family."

Villavicencio, who is originally from Ecuador, was arrested on June 1 while delivering a pizza to the Fort Hamilton Army base. He says a guard on duty at the base asked to see his identification and Villavicencio produced a municipal identification card, but the guard refused to accept it. The officer then ran a background check on Villavicencio and discovered a pending deportation order from 2010. He was then turned over to ICE officials.

In 2013, Villavicencio married Sandra Chica, a naturalized citizen. The couple have two small children.

Gregory Copeland, a lawyer representing Villavicencio from the Legal Aid Society of New York, called the judge's order "absolutely sensational."

As The New York Times notes, "The order came after a morning hearing in which ... Crotty , an appointee of President George W. Bush and the former corporation counsel for Mayor Rudolph Giuliani, pointedly questioned the government about why it had detained Mr. Villavicencio and planned to deport him. "Is there any concept of justice here?" Judge Crotty asked the government's lawyer."

According to The Associated Press, "Villavicencio walked out of the immigration detention center shortly before 9 p.m. Tuesday and was greeted with hugs from his jubilant wife and two young daughters. He thanked supporters and the media before being whisked away in an SUV."

Copyright 2018 NPR. To see more, visit http://www.npr.org/.