The gunman fatally shot himself after trying to set himself on fire at Bronx Lebanon Hospital.

A doctor forced from a New York hospital because of sexual harassment accusations returned on June 30, 2017 with an assault rifle hidden under a lab coat and shot seven people, killing one woman and leaving several doctors fighting for their lives, authorities said.

The gunman, Henry Bello, fatally shot himself after trying to set himself on fire at Bronx Lebanon Hospital, they said. He staggered, bleeding, into a hallway where he collapsed and died with the rifle at his side, officials said.

Witnesses described a chaotic scene as gunfire erupted, spreading terror throughout the medical facility as employees locked themselves inside rooms and patients feared for their lives.

“I thought I was going to die,” said Renaldo Del Villar, a patient who was in the third-floor emergency room getting treatment for a lower back injury.

Law enforcement officials identified the shooter as the 45-year-old Bello, who was described on the hospital website as a family medicine physician. Officials said Bello used an AR-15 in the attack on the 16th and 17th floors.

Bello was allowed to resign from the hospital in 2015 amid sexual harassment allegations, according to two law enforcement officials. The officials didn’t know the details of the allegations.

The officials were not authorised to discuss the still-unfolding investigation and spoke to The Associated Press on condition of anonymity.

In unrelated cases, the doctor pleaded guilty to unlawful imprisonment, a misdemeanour, in 2004 after a 23-year-old woman told police Bello grabbed her, lifted her up and carried her off, saying, “You’re coming with me”. He was arrested again in 2009 on a charge of unlawful surveillance, after two different women reported he was trying to look up their skirts with a mirror.

On June 30, 2017, one female doctor was killed and six other people were wounded, five of them seriously, according to Police Commissioner James O’Neill. The patients were treated in the emergency room at Bronx Lebanon.

A surgeon at the hospital told the AP that all six victims were in critical condition, but they were expected to survive. The victims largely suffered gunshot wounds to the head, chest and abdomen, he said. The most seriously wounded was shot in the liver, said the surgeon, who spoke on the condition of anonymity because he was not permitted to speak publicly.

“This was a horrible situation unfolding in a place that people associated with care and comfort, a situation that came out of nowhere,” Mayor Bill de Blasio said, adding that terrorism was not involved in the attack.

Shortly after receiving a 911 call about an active shooter, police officers went floor by floor, their guns drawn, looking for the gunman. They later learned he was dead inside the building. Mr. De Blasio confirmed that Bello killed himself.

Bello may have doused himself with an accelerant like petrol and tried to set himself on fire before shooting himself, officials said. Sprinklers extinguished the fire.

According to New York State Education Department records, Bello had a limited permit to practice as an international medical graduate to gain experience in order to be licensed. The permit was issued on July 1, 2014, and expired in 2016 on the same day.

A former colleague described Bello as a problematic employee.

Bello “was very aggressive, talking loudly, threatening people. All the time he was a problem”, said David Lazala, a family medicine doctor who said he trained Bello at Bronx Lebanon.

Employees and their loved ones described the horrifying moments immediately after the shooting as they scrambled for information.

Garry Trimble said his fiancée, hospital employee Denise Brown, called from inside to tell him about the gunman.

“She woke me up and told me there was a situation, somebody’s out there shooting people,” Mr. Trimble said as he waited for Ms. Brown to leave the hospital. “I could hear in her voice she was shaking and about to cry.”

Gonzalo Carazo told WCBS-TV that he saw a doctor with a gunshot wound on his hand.

“All I heard was a doctor saying, “Help, help!” Mr. Carazo locked himself in a room for about 15 minutes until police came and led him out of the hospital.

The 120-year-old hospital has nearly 1,000 beds and one of the busiest emergency rooms in New York City. It is about a mile and a half north of Yankee Stadium.

In 2011, two people were shot at Bronx Lebanon in what police said was a gang-related attack.