An ex-con from Queens was charged today with possession of an illegal handgun and assaulting a cop after the revolver went off and struck the officer.

Edwin Santana, 33, was arraigned in Queens Criminal Court and held on $100,000 bail after Officer Rodney Lewis was hit by the bullet as he and his partner responded to a domestic dispute early Sunday in Ridgewood involving two men and a transexual.

Lewis, a four-year NYPD veteran assigned to the 104th Precinct station house, was struck on the left side of his chest and remains in stable condition at New York Hospital.

The shooting occurred after a 911 came in to the 104th Precinct station house that a woman, who calls herself “Hazel” Campana, was fighting with her boyfriend Carlos Berrios.

Campana, a transexual who was born a man, got into a fight with Berrios. Campana called Santana, her ex-boyfriend, and that’s when he went to the house to help her.

That’s when, police said, officers arrived. While Santana was being frisked, his gun fell to the ground from his waistband and fired one shot.

“I had the gun, but I didn’t shoot nobody,” Santana told cops, according to prosecutors.

During his court appearance, prosecutors said Santana was once convicted of murder in 1991 as a juvenile and was wanted on a parole violation. He served 15 years in prison, but had failed to report recently to his parole officer.

If convicted, Santana, who pleaded not guilty to the charges, could face up to 15 years in prison.

The Queens DA is expected to present the case to a grand jury later this week.

“This case underscores yet again the dangers faced by New York City police officers every day,” said Queens DA Richard Brown. “There is nothing routine or predictable about police work.”