A disgruntled doctor’s suicidal rampage Friday afternoon at Bronx-Lebanon Hospital Center began with a gunpoint confrontation with a former colleague at a 16th floor nurses’ station, a senior NYPD official said.

“Why didn’t you help me out when I was getting in trouble?” Dr. Henry Bello shouted before opening fire with an AM-15 assault rifle, according to the official.

Bello missed that target — a physician, who survived by fleeing to a nearby room, the source said. But the gunman wounded others and then went up to the 17th floor, where the carnage continued.

As the hospital went into Code Silver — activated in cases of an unauthorized armed person on the loose — Bello went on to kill a young family medicine doctor he didn’t know, and wound six others, including physicians, medical students and a patient, authorities and hospital officials said.

After first trying to set himself on fire using a container of flammable liquid, Bello, 45, took his own life by shooting himself in the chest, the NYPD source said. His body was found in a 17th floor hallway.

Investigators have recovered eight shell casings, the source said.

advertisement | advertise on newsday

The doctor who was killed was identified Saturday by the NYPD as Tracy Sin-Yee Tam, 32, of Jamaica, Queens, a 2013 graduate of Touro College.

Tam, who practiced family medicine, wasn’t supposed to be working Friday, but was substituting for a colleague who was off, the hospital said.

Five of the shooting victims were expected to recover from injuries ranging from abdomen to hand wounds, said Dr. Sridhar Chilimuri, the hospital’s physician in chief. A sixth victim — a doctor who was shot in the head — remained in critical condition Saturday night.

As shaken employees returned to work, a portrait began to emerge of a troubled man who nursed a grudge from the time Bronx-Lebanon threatened in 2015 to fire him over sexual harassment allegations if he didn’t quit.

About two hours before the shooting began shortly before 3 p.m., Bello, 45, emailed The Daily News, blaming the hospital for ruining his career over “bogus complaints,” the newspaper reported Saturday.

“This hospital terminated my road to a licensure to practice medicine,” Bello wrote. “First, I was told it was because I always kept to myself. Then it was because of an altercation with a nurse.”

The NYPD official said Bello singled out one doctor in particular for plotting to get Bello fired, but that person wasn’t present at the time of the rampage.

“We interviewed the doctor who was the original intended target, who said the shooter was always belligerent and would get into verbal arguments with nurses and staffers,” the official said.

advertisement | advertise on newsday

When Bello was forced out in 2015, he emailed the doctor, congratulating him for getting his wish, the source said.

Bello was hired as a house physician in August 2014 but resigned the following February to avoid being fired, said hospital spokesman Errol Schneer.

Schneer said the hospital is investigating how Bello, who apparently hid the assault rifle under a white lab coat, was able to easily pass through security.

There was no indication that Bello would return to commit violence so long after his ouster, Schneer said.

“There was no warning whatsoever that he would return or that he would ever take this type of action,” he said.

advertisement | advertise on newsday

The condition of most of the shooting victims has improved, with the exception of the critically injured doctor, who has not been publicly identified.

Chilimuri said that doctor was shot in the brain and knee, and would be transported to Mount Sinai Hospital in Manhattan for further treatment after surgery.

Counseling was being provided for employees coping with the tragedy. In the aftermath of the shooting, the physician for whom Tam was covering was “totally grief-stricken,” Schneer said.

The 16th and 17th floors remained a crime scene Saturday, and the 40 to 60 patients were moved elsewhere in the hospital. The 15th floor was also closed and patients moved, because of flooding caused by the sprinkler system, which was triggered when Bello set the fire.

Inside the sixth-floor Sheridan Avenue apartment where Bello lived, about a mile from his former hospital, officers found the box for the Anderson AM-15 rifle, the NYPD source said.

Bello’s family could not be immediately reached.

Online court records show Bello was charged in 2004 with sexual abuse and unlawful imprisonment, both felonies, and misdemeanor unlawful imprisonment. He pleaded guilty only to the misdemeanor and was sentenced to 28 hours of community service, according to records.

With Jesse Coburn and Mark Morales