A Manhattan federal judge has blasted the Trump administration’s “zero tolerance” policy toward illegal border crossings as “thoughtless and cruel” and a “mercurial exercise of executive power.”

Judge Paul Crotty made the comments in a court filing Wednesday to explain his July decision to release Pablo Villavicencio, also known as “Pizza Guy,” from ICE detention.

“It should not be difficult to discern that families should be kept together rather than be separated by the thoughtless and cruel application of a so called ‘zero tolerance’ policy,” Crotty said in the filing.

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

But instead of packing it up and deporting himself, he married an American citizen, had two kids, worked hard and paid his taxes, the judge said.

More recently, he “commenced the process of regularizing his immigration status to become a lawful permanent resident” when ICE caught up to him, the judge said.

The judge blasted ICE for seeking to deport Villavicencio while he was going through a process established by the Department of Homeland Security to allow people like him to override an order of removal.

Villavicencio “should be allowed to pursue the pathway,” the judge said. “This is especially so where the organization seeking removal has also provided a pathway.

“He deserves it due to hard work, his dedication to the family, and his clean criminal record.

“There is no justification for this mercurial exercise of executive power,” the judge said.

Crotty ordered Villavicencio released from the Hudson County Correctional Facility in Kearny, NJ, on July 24 but waited until now to explain his decision.