The ​illegal ​Ecuadorian immigrant tossed in detention after he delivered a pizza to a Brooklyn army base was ordered released from ​custody Tuesday and his deportation was temporarily halted.

Pablo Villavicencio, also known as “Pizza Guy,” is expected to be released from the Hudson County Correctional facility in Kearny, NJ, Tuesday​ night​, according to a representative of the Legal Aid Society, which has been fighting his deportation.

Villavicencio, 35, was ordered deported after a​n unusual ​background check during a ​food delivery to ​Fort Hamilton in Bay Ridge found he had been ordered removed ​from the U.S. ​in 2010.

But Manhattan federal judge Paul Crotty sa​id Villavicencio has the right to try to obtain waiver to kill the 2010 order of removal.

“The court holds that he indeed does have a right to complete the process of obtaining a provisional waiver and that the government’s deportation of petitioner would contravene that right,” the judge said ​in a Manhattan federal court ​filing Tuesday.

The judge ordered that Villavicencio’s deportation is stayed until he “exhausts his right to complete the process of obtaining a provisional waiver.”

The judge also ordered that he be released from detention.

“Although he stayed in the United States unlawfully and is currently subject to a final order or removal, he has otherwise been a model citizen,” the judge said.

“He has no criminal history. He has paid his taxes. And he has worked diligently to provide for his family,” including his US citizen wife and two daughters, the judge said.