A masked bandit’s clip fell out of his gun after he tried to fire at the head of a Queens bodega clerk – who used an unlicensed gun to plug him instead, prosecutors said yesterday.

Edwin Marte, 35, a clerk at Ramon Food Market in Ozone Park, wept after he was released without bail following his arraignment in Queens criminal court on a misdemeanor weapons charge.

Prosecutor Stephen Geller read a statement in court that Marte gave cops telling how he was in the store Wednesday night watching TV when a man walked in and “put on his black mask by the deli” section.

“Hold up! hold up! hold up!” the masked man yelled as he pulled out a gun, the clerk told cops.

Marte grabbed for a weapon he knew was in the store but that did not belong to him, he told cops. Police said it was a .38-caliber revolver.

“We pointed to each other’s heads and we shot,” he said in the statement.

Then the would-be stickup man’s clip fell to the floor, he said.

Cops said Marte’s shot struck Devin Keitt, 26, behind the ear. The bullet missed his brain and exited at the back of his head.

“He ran out like a crazy man,” Marte said in the statement, insisting, ” I defended myself. I told them [police] that the revolver was in the store. And I gave it to them.”

Keitt, of Brooklyn, was in stable condition yesterday at Jamaica Hospital and is expected to be charged with attempted robbery and menacing, law-enforcement sources said.

Cops found a 9 mm magazine at the scene with six live rounds in it, the sources said.

In 2000, Keitt pleaded guilty to three instances of criminal possession of stolen property involving the theft of three cars. In September 2000, he was sentenced to 2½ to five years and was conditionally released on Sept. 10, 2003.

Marte, who has an 8-year-old daughter, was charged with criminal possession of a weapon in the fourth degree, a misdemeanor. He was released without bail with the consent of Queens District Attorney Richard Brown, who said that based on a preliminary review, it would appear he “acted in self-defense when he fired at an armed assailant inside his grocery store.”