A federal district court judge on Tuesday ordered the immediate release of Pablo Villavicencio Calderon, an undocumented pizza delivery man, from immigration detention in New Jersey, where he had been locked up since June 1.

The order came after a morning hearing in which Judge Paul A. 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.

Later in the day, the judge said that Mr. Villavicencio, 35, who is married to a United States citizen and in February began a petition for a green card, should be released. The judge granted a stay of deportation while Mr. Villavicencio pursues permanent residency.