Uniformed cops stepped out of their marked car and approached the suspect, who then ran, turned around and fired on the officers as he fled, police added.

Cops returned fire and hit the alleged shooter in the right thigh but that didn’t stop the gunman, cops said.

More officers, who were called for backup, confronted Carew, who finally dropped the .380 caliber semiautomatic handgun, police said.

Investigators then learned that what 911 callers had heard was Carew firing on a 53-year-old man who tried to escape as Carew tried to rob him at gunpoint, cops added. The victim was not injured, police said.

Carew was taken to Elmhurst General Hospital, where he’s listed in stable condition.

He is charged with two counts of attempted murder of a police officer, one count of attempted murder, robbery and criminal possession of a loaded firearm.

Three cops — a sergeant and two officers — were taken to area hospitals for ringing in the ears.