SAN JOSE — A 14-year veteran San Jose police officer was killed Tuesday evening in a dramatic series of events that began with a call about a suicidal man and ended when police used explosives and a robot to breach the suspect’s apartment, but found him dead.

The killing of Officer Michael Johnson was the department’s first line-of-duty death in 14 years. He was fatally wounded as he responded to an apartment complex in the 2600 block of Senter Road around 6:48 p.m. Tuesday.

Johnson was the 12th SJPD officer killed in the department’s 166-year history. He was a field training officer at the time of his death.

Now, the SJPD community is reeling from an experience it has been spared from for nearly a decade and a half: mourning the loss of a comrade who gave his life to protecting the public.

“Officers are obviously crying, grieving, they will obviously do so for some time. Our hearts, our prayers go out with the family of Michael, our brother. This is a very difficult time right now,” police spokesman Officer Albert Morales said early Wednesday. “Rest assured we’ll keep him in our memories as we go out there and continue to do the job we loved to do and I’m sure that he loved to do.”

Adding to the heartache was the fact Johnson came from the same police academy class as Jeffrey Fontana, the last officer killed in the line of duty. Fontana was in his rookie year on the force when he was shot to death during a high-risk vehicle stop in South San Jose on October 28, 2001.

“As a chief this is not something we would ever want to do,” San Jose police Chief Larry Esquivel said at a news conference late Tuesday. “It’s a sad day for law enforcement and for the police department and the community.”

A statement from the San Jose Police Officers Association said all officers were grieving for Johnson, who leaves behind a wife.

“Our thoughts and prayers go out to Officer Johnson’s family and friends,” the union said. “(Johnson) was tragically struck down in the prime of his life protecting and serving the residents of San Jose.”

Mayor Sam Liccardo, who added that he offered condolences to the slain officer’s family on behalf of the city, said, “This is San Jose’s darkest hour. This strikes the heart of all of us in San Jose and throughout the region.”

Police identified the suspect in Johnson’s slaying late Tuesday as Scott Dunham, 57. Officials launched a massive manhunt after the attack with a detail consisting of dozens of officers and the MERGE (SWAT) unit, who all swarmed the area of Senter and Umbarger roads to find the gunman.

Nearby homes were evacuated as officers and equipment — including armored vehicles and a helicopter — were summoned from neighboring police agencies, including the Santa Clara County Sheriff’s Office, Santa Clara and Sunnyvale police, and the California Highway Patrol.

The manhunt continued for hours, with police eventually converging on the building that housed Dunham’s apartment. Officials said around 11 p.m. that they believed that Dunham might still be inside the apartment, but they were also chasing down leads that indicated he might be elsewhere.

Police breached his apartment using explosives around 1:30 a.m., then began a slow, exhaustive search using a robot with a camera. Officers at the scene confirmed that Dunham had been found dead on the apartment’s balcony shortly before 3:30 a.m.

It was not immediately clear how Dunham had died, though police said he had suffered at least one gunshot wound. Police reported earlier that he may have been wounded during the exchange of gunfire that killed Johnson. Esquivel acknowledged the possibility that Dunham might have been dead for most of the standoff, as officers never made contact with him after the initial clash, and there was no subsequent gunfire.

San Jose officers were initially called at 6:48 p.m. Tuesday by a female family member who said that Dunham was intoxicated, despondent and possibly meant to harm himself or others, Esquivel said. As the officers approached the apartment building on Senter Road and spotted a person on a balcony, they were fired upon without warning.

Police dispatch recordings show that officers told dispatchers they believed the man they were searching for had one or two handguns in the apartment.

At one point, as they approach the apartment, an officer says “we have movement from the blinds at the apartment.”

An officer calmly reports that a male has stepped out onto the balcony, describing him as having gray hair, a gray mustache and a black T-shirt. Seconds later, the “shots fired” call can be heard, followed almost immediately by the “officer down” call.

Dispatchers immediately called for the area to be secured and put out a citywide call for assistance. Another officer reported that shots were fired at the suspect, and that he possibly “went down as well.” Esquivel confirmed the gunfire exchange and the possibility that Dunham was wounded.

“This person had the nerve, the audacity, to shoot at our officers who were on a call for assistance,” Esquivel said.

An outpouring of grief flowed from both members of the public and law enforcement agencies throughout California and across the nation Tuesday night. Hundreds of social media users sent their condolences to San Jose police through the department’s Twitter account.

“It’s extremely painful and shocking,” said Councilman Tam Nguyen, who represents District 7, where the shooting occurred. “I’m worried for the safety of other officers.”

Staff writers Eric Kurhi and Mark Gomez contributed to this report.