An attempted robbery suspect was shot by an off-duty San Francisco police officer in the city's Lower Nob Hill neighborhood Wednesday morning, a police spokeswoman said.

A passerby saw a male suspect trying to break into a car around 6 a.m. and confronted him. The suspect then struck the passerby with a wooden object and robbed him, Sgt. Monica MacDonald told Bay City News.

The suspect made his way into a nearby apartment building, where the off-duty police officer was exiting an apartment in the building and encountered him in a hallway, MacDonald said.

The suspect then tried to rob the officer, who identified himself and drew his weapon, the sergeant said. The suspect refused to comply and told the officer that he would have to have to kill him, MacDonald said. The officer holstered his handgun, and the two became engaged in a physical struggle, according to police. The officer called for backup during the fight, during which the suspect struck the officer and bit him, causing lacerations, MacDonald said.

The suspect then reached for the officer's gun, which discharged once, striking the suspect in the upper body, MacDonald said. She said blood was found all over the hallway inside the apartment building when on-duty police officers arrived.

The wounded suspect was located and taken to the hospital.