Lawyers say they’ve won an emergency stay blocking the deportation of an Ecuadorean man who was turned over to immigration officials after making a pizza delivery to an Army base in New York.

The Legal Aid Society said Saturday that an emergency stay was granted barring the immediate deportation of Pablo Villavicencio, a 35-year-old father of two, who was detained by military police and turned over to Immigration and Customs Enforcement on June 1.

A judge granted the stay until July 20, but Villavicencio will remain detained, the Legal Aid Society said. The case has sparked outrage from his family and local officials.

"Although we are disappointed that Pablo will remained detained, today’s stay is a victory for him and his family, and also for due process and the fair administration of justice," Gregory Copeland, Supervising Attorney of the Immigration Law Unit at The Legal Aid Society, said in a statement.

Villavicencio is an Ecuadorean citizen and was granted voluntary departure in March 2010, but failed to leave the country by July 2010 as ordered, ICE said in a previous statement. His voluntary departure then became a final order for removal.

Villavicencio was detained after delivering pizza to Fort Hamilton in New York City, officials said.

United States Army Garrison Fort Hamilton said in a statement this week that at around 11 a.m. on June 1 a person tried to gain access to the base without valid Department of Defense identification.

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

The person, later identified as Villavicencio, was sent to get a daily pass and signed a waiver submitting to a background check, something standard for all visitors. The check revealed an active ICE warrant on file, Fort Hamilton said.

The Legal Aid Society said the emergency stay was based on a habeas corpus petition filed Saturday morning, and that the stay will allow him to pursue relief from removal.

Villavicencio’s wife, who is an American citizen, has said that her husband has a pending green card application they filed in February. She said that he presented an IDNYC card, a city government-issued form of identification, and that he never had a problem before.

Copeland, of the Legal Aid Society, said in the statement that the court agreed that Villavicencio “should be afforded a full and fair opportunity to present his case in Federal Court.”

New York Gov. Andrew Cuomo, a Democrat, who on Friday called for an investigation into ICE conduct, wrote a letter to the field director for the Department of Homeland Security in support of an application for a stay of removal, and requested that Villavicencio be released from ICE custody.

Cuomo wrote in the letter that when Villavicencio made the delivery to the base, "it appears that there was conflict among those personnel as to whether Mr. Villavicencio needed to provide any additional identification because he was known to them based on previous deliveries he had made to the facility."

Cuomo said that Villavicencio has been a resident of New York City for over 10 years, and that "he is a working father, a taxpayer, and the primary provider for his U.S. citizen wife and two daughters, one of whom suffers from a serious medical condition."

"The circumstances of this case, including the arrest and detention of Mr. Villavicencio and the remarkable speed with which it appears he is being removed, reflects a pattern of conduct which I have previously raised with ICE as unconscionable and seemingly targeted directly at New York residents," Cuomo said in the letter. "There is absolutely no legitimate reason to proceed with an expedited removal and to do so would be inhumane."

CORRECTION (June 16, 2018, 9:40 p.m. ET): A previous version of this article misstated the date of a stay in the case. The stay was granted until July 20, not June 20.