An off-duty correction officer being hailed as a hero for stopping a shooting was released from the hospital Monday morning, officials said.

"He is a hero. Taking proper action while off-duty is one of the most difficult things to do, and we are happy that he is not experiencing any life-threatening injuries," Mayor Eric Adams said at a news conference Sunday night.

According to police, off-duty officer David Donegan saw a man pointing a gun at a crowd. The 42-year-old officer subsequently drew his firearm and shot at the 23-year-old suspect, hitting him in the torso. 

During the exchange, the officer was struck in the leg. Police do not know who he was shot by, or how the third person relates to the incident.

The shooting took place during a Fourth of July celebration Sunday night in Queens, police said. Adams blamed "a failing criminal justice system" for gun violence in New York City during a news conference after the incident.

"This is a perfect example of a failing criminal justice system that continues to produce the violence that we are experiencing," Adams said. "This is a pattern that continues to play out across the landscape of our city: too many bad people carrying guns and back on our streets without any repercussions for their actions."​