A disgruntled doctor armed with an AR-15 rifle and wearing a lab coat went on a rampage on Friday in the Bronx hospital where he had worked, killing a doctor and wounding six other people — five of them seriously — before setting himself on fire and shooting himself in the head, the authorities said.

The furious attack by the doctor — identified by the police as Henry Bello, 45 — sent workers at the hospital, Bronx-Lebanon Hospital Center, diving behind desks and doors as gunshots and smoke filled the hallways of a place devoted to healing. Witnesses described medical workers ripping a fire hose from the wall to use as a tourniquet on one victim’s leg, while others recalled the horrific sight of the gunman, his torso aflame, running down a hallway.

Dr. Bello had a troubled past, having worked at the hospital for about six months before quitting after being accused of sexual harassment, officials said. And years earlier, he was arrested and charged with sexual abuse after assaulting a woman in Manhattan.

Image Henry Bello

The attack appeared to be the type of mass shooting by a lone gunman that has struck communities around the United States.

“He’s shooting! He’s shooting!” one woman yelled in the frantic initial moments of the afternoon assault, as recounted by a mother in the pediatric emergency room who had cowered with her five children, ages 1 to 10.

Some believed that the death toll would have been far higher had the shooting occurred anywhere but where it did — a hospital filled with state-of-the-art medical equipment, and with doctors and nurses who rushed to victims and performed triage where they fell, in staircases and hallways, even as the gunman was still at large.

“The situation unfolded in the middle of a place that people associate with care and comfort,” Mayor Bill de Blasio told reporters outside the hospital, on the Grand Concourse in the Claremont Village neighborhood. The gunman acted alone, Mr. de Blasio said, adding that it appeared to be a workplace dispute that ended when the gunman committed suicide — “but not before having done horrible damage,” the mayor said.