A man threatening to commit suicide unleashed a barrage of gunfire on Northern California police officers called to check on him, killing a 14-year veteran of the San Jose department in the agency's first on-duty death in 14 years.

Scott Dunham, 57, fatally shot Officer Michael Johnson Tuesday night, launching an hourslong manhunt for the gunman and forcing nearby homes to be evacuated. The search ended when Dunham was found dead early Wednesday on his apartment balcony, San Jose police spokesman Albert Morales said.

Police had no communication with Dunham between the time Johnson was shot about 6:45 p.m. Tuesday and the time Dunham was found dead more than eight hours later, at 3:20 a.m. Wednesday. It was unclear if he killed himself or died when officers returned fire. He may have been dead the entire time, police said.

Officers approaching Dunham's San Jose apartment building were met with gunfire. After Johnson was shot, authorities swarmed the area in search of the shooter. Officers, armored vehicles and a helicopter came from neighboring law enforcement agencies and the California Highway Patrol.

The last San Jose officer killed in the line of duty was Jeffrey Fontana, who was shot during a vehicle stop in 2001. That gunman, DeShawn Campbell, was convicted in the case.

Coincidentally, both Johnson and Fontana were in the same police academy class.

Johnson is the 12th officer to be killed in the San Jose Police Department's 166-year history and leaves behind a wife, who was out of town at the time of the shooting, police said.