A prisoner escaped from city police after a Brooklyn robbery, cops said Tuesday.

The wanted man was arrested by officers with the New York City Department of Homeless Services Police around 11:30 p.m. Monday when he tried to mug a man at a homeless shelter in Bedford-Stuyvesant, according to police.

The accused, believed to be homeless, escaped custody while he was being processed, cops said.

The NYPD was assisting in the search, but Homeless Services Police took the lead in the investigation.

The agency did not immediately respond to an email for more details.