About 5 p.m., Officer Li and his partner, Randy Chow, had just removed Mr. Robinson and another man from a B46 bus traveling south on Utica Avenue after they saw the men board a bus through a back door without paying the fare, the police said. Mr. Robinson ran, and when Officers Li and Chow gave chase, he fired on the officers, Chief Banks said. Officer Li was injured in the left thigh, right thigh and groin, he said.

In return, Officer Li fired five shots and Officer Chow fired twice, he said. Mr. Robinson was not hit.

Bystanders — including two off-duty emergency medical technicians — provided Officer Li with first aid while Officer Chow radioed for help and continued to chase the suspect, according to fire and police officials. With help from local residents, officers found Mr. Robinson in a fifth-floor hallway of an apartment building at 445 Schenectady Avenue and took the handgun from him, Mr. Banks said.

Mr. Robinson had previously been arrested six times, and there was an active warrant for his arrest in Lebanon, Pa., on charges of narcotics manufacturing and distribution, Chief Banks said. The other suspect who was pulled off the bus had not been found, he said.

Officer Chow, 30, and a female officer whose name was not released were treated for minor injuries, the police said.