A longtime New York City detective assigned to Mayor Michael Bloomberg's security detail was charged Friday with shooting and injuring his girlfriend's ex-boyfriend in a confrontation this month.

Leopold McLean, 46, was released on bail after appearing in a Queens court to face second-degree attempted murder, first-degree assault and other charges. He was suspended from the force pending the outcome of the case.

Defense attorney Gilbert Parris described his client as a decorated detective with an impeccable record in his 17 years with the New York Police Department.

"There's nothing in his background that would lead him to use unjustifiable force," Parris said.

Prosecutors allege that the off-duty McLean pulled a gun on Lepaul Gammons outside his girlfriend's home Nov. 12. Authorities say the unarmed man turned up there in violation of a restraining order.

When Gammons asked the officer if he was going to shoot him, McLean "stated he had something for Gammons and lowered the black handgun and reached down toward his ankle," prosecutors say.

Gammons tried to flee on foot. Prosecutors say he heard gunfire before a bullet hit him in the buttocks.

McLean had been assigned to the team of officers that does security sweeps of locations scheduled for visits by Bloomberg.