NYPD officers and brass cheered Monday as an off-duty detective who was repeatedly stabbed during an attempted robbery in the Bronx was released from the hospital.

Det. Jose Mercedes, his hand in a cast, flashed a smile and give a thumbs-up as Police Commissioner Jessica Tisch and his fellow Finest applaud his recovery outside Jacobi Medical Center, video posted by the Detectives’ Endowment Association shows.

“Not only are detectives here today, there’s bosses here today, there’s police officers, every rank is here today to support him leaving, because he’s a real hero,” said Scott Munro, president of the Detectives’ Endowment Association.

The detective was retrieving something from the trunk of his black Mustang parked in front of a single-family home on E. 208th St. near Steuben Ave. in Norwood around 2 p.m. Friday when two men crept up behind him and tried to steal his gold chain, law enforcement sources said.

The 33-year-old victim was stabbed up to seven times, sustaining wounds to his neck and torso, as he fought off the would-be robbers, sources said.

The two suspects fled on an e-bike, but the off-duty cop gave chase, pursuing them for about two blocks to Rochambeau Ave. near E. 206th St., where he collapsed.

“He got stabbed, and he was chasing the guy,” said a witness, who asked that his name be withheld. “He chased the guy, and that’s where he collapsed, in front of the building where I was sitting. We know him from the neighborhood, so we know he’s a cop.”

The suspects, who fled empty handed, remain at large.