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.

According to San Francisco police Sgt. Monica MacDonald, police received reports shortly before 6 a.m. of gunshots heard in the area of Leavenworth and Pine streets.

Officers responded to the area but were unable to find anything out of the ordinary, MacDonald said. She said based on the preliminary police investigation, it appears someone was trying to break into a car by smashing a window with a wooden stick, possibly a chair leg.

A passerby saw the male suspect and confronted him. The suspect then struck the passerby with the wooden object and robbed him, MacDonald said.

The victim didn't initially report the incident and went home to clean himself up and get ready for work, according to the sergeant.

The same passerby was then walking to work when he saw an altercation inside Another Café, a coffee shop at Leavenworth and Pine. The same suspect allegedly threw coffee on someone inside the coffee shop and then exited, MacDonald said.

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 suspect, whose name is not yet being released, was transported to San Francisco General Hospital, according to MacDonald. She did not know his condition. She said the off-duty officer, whose name is also not immediately being released, teaches defensive tactics at the department.