A man accused of stealing a salami from a Brownsville grocery store ran himself into much more serious charges yesterday, when he escaped from cops holding him in a detention area in Brooklyn Criminal Court.

If he’d just waited to see a judge, Ortega, 36, probably would have been freed on bail and hit with minor counts, said a law-enforcement source.

But by running, he added a felony charge of escaping a detention facility to the misdemeanor petit larceny and possession-of-stolen-property charges he faced for allegedly shoplifting the salami.

Ortega ran off at 2:15 p.m., as 73rd Precinct cops led him and another prisoner back to their cells after a bathroom break.

He was back in police custody four hours later.

Ortega was initially busted Monday afternoon by a security guard who caught him taking the salami from a Food Bazaar store on St. John’s Place.