A Philadelphia police detective, in an unmarked car stopped at a Kensington intersection Monday night, shot and wounded a panhandler who he thought was armed and possibly about to rob him, officials said Tuesday.

The man, whom relatives identified as 28-year-old Joel Johnson, was well-known around G and Tioga Streets, where residents say he spent nearly every day asking people for change, often by extending his arms and rubbing his fingers together.

About 8:45 p.m. Monday, according to police, witnesses, and surveillance video obtained by The Inquirer, Johnson was walking past cars stopped at a red light on the 3400 block of G when he approached the driver’s side window of a detective’s car.

Police Commissioner Richard Ross said in an interview that the detective, an eight-year veteran whom he did not identify, “thought he was being carjacked” and fired three shots at Johnson through the closed car window, striking him once. (Police later updated the official account to say the detective fired four shots.) Ross said the detective, assigned to East Detectives, was alone in the car and had just been at a crime scene.

Surveillance video appears to show a few seconds passing between the moment Johnson approached the front of the detective’s car and the first shot. The video shows what looks like a plume of smoke or shattering glass coming from the driver’s side window, and Johnson falling to the ground.

Geovany Cardoza, 32, said in an interview on the block Tuesday that he was across the street in front of his house when he heard the shots, which he initially mistook for fireworks. When he turned around, he said, he saw the detective get out of the car and yell: “‘Don’t move! Where is the gun?’”

Cardoza, who said he knows Johnson from the neighborhood and sometimes gives him food or drinks, said he eventually approached the detective to tell him that Johnson — whom he described as harmless — would not have a gun. Cardoza wondered how the detective did not see Johnson slowly making his way past cars to ask for change, and said that children were outside in the moments around the shooting.

“One of the missing shots [could] have hit the kids,” Cardoza said.

Johnson was shot once in the torso and was reported in critical condition at Temple University Hospital. Ross said he was expected to survive.

Captain Sekou Kinebrew, a police spokesperson, told reporters at the scene that the detective “believed what he saw was a firearm in this male’s hands. The detective, believing he was going to be robbed or something was going to happen to him, produced his firearm, discharged his firearm we believe at this time three times."

People who said they were relatives of Johnson’s declined to comment Tuesday morning, except to identify him.

Khalif Bolling, 50, said he lives nearby and recognized Johnson as a constant presence around the intersection. He said Johnson did not bother people or seem to cause trouble.

William Bowens, 36, who was talking with Bolling near the corner Tuesday morning, said he couldn’t understand how a detective could mistake Johnson’s panhandling for threatening behavior.

“For him to get shot, that’s just wrong,” Bowens said.

Internal Affairs will investigate the shooting. The detective has been placed on desk duty, which is standard procedure when an officer shoots someone.

The shooting marked the fifth time this year that an officer has opened fire while on duty, according to police statistics. Last year, the department reported 12 incidents in which police officers fired shots, the lowest annual total in at least a decade.

Staff writer Joseph A. Gambardello contributed to this article.