A man being arrested for smoking marijuana on a Brooklyn street corner yesterday grabbed a gun from a cop’s holster — then wrestled with him for the weapon and managed to squeeze off a round, sources said.

Although he fired at point-blank range, no one was hit.

The 26-year-old suspect was spotted lighting up by a lieutenant and an officer on patrol at 6:15 p.m. at Malcolm X Boulevard and Lexington Avenue in Bedford-Stuyvesant, authorities said.

When the cops approached the man, he grew unruly as they were trying to slap the cuffs on him.

He then somehow took control of the officer’s gun during the skirmish, according to the sources.

The officer managed to keep his hands on the barrel of the weapon as the thug fired one shot that just missed.

Then the shell casing jammed inside the gun, keeping the pot-smoking attacker from firing any more shots, the sources added.

The cop then took back his gun and finally arrested the suspect.

Charges were pending last night.

Both cops were taken to Wyckoff Heights Hospital.

One suffered an injured shoulder and back, and other injured an elbow, cops said.