The shooting started a little before 3 p.m. ET at the Bronx-Lebanon Hospital. The 972-bed facility is one of the largest providers of outpatient services in New York.
Police said somebody called 911 to report a man with a gun on the 16th floor.
Police converged on the scene and officers found the gunman dead of a self-inflicted gunshot wound on the 17th floor, New York City Police Commissioner James O'Neill said at a news briefing.
The man was wearing a white lab coat and carrying ID and his firearm was nearby, O'Neill said.
The shooter, Henry Bello, was a "disgruntled (former) employee" who worked at the hospital from August 2014 to February 2015, a hospital spokesman said. Errol Schneer told reporters that Bello resigned before he was to be fired.
Schneer said Bello likely did not know any of the people he shot, but that police are investigating the matter.
The body of a female doctor was found close to the gunman's body, O'Neill said. The woman's name was not immediately released.
Sridhar Chilimuri, Physician-in-Chief at the hospital, said the victim was shot at random.
Six people were wounded on the 16th floor, and five -- who are hospital staff members -- are in serious condition from gunshot wounds. They are all in the intensive care unit, Chilimuri said.
Another person, who was already a patient, was injured and is in stable condition.
The hospital's fire alarm system went off during the siege, apparently because the shooter tried to set himself on fire, O'Neill said.
So far authorities have not offered a motive. The FBI said the shooting did not appear to be an act of terrorism
. New York Mayor Bill de Blasio called it an act of work-related violence.
Chilimuri said hospital officials were unhappy with Bello's performance and he left two years ago under "unfortunate circumstances."
Video images from the scene showed hospital employees and others coming out of the hospital's main entrance, their hands in the air, and crossing the street toward awaiting police officers.
Scenes from the hospital
Employees and patients described scenes of panic in the crowded hospital, with people taking shelter in closets and rooms.
Krystal Rivera, a 23-year-old patient at the hospital, said she was with her hospital roommate, a visitor and a nurse from the floor when they heard gunshots.
"I barricaded the door with an IV machine, two chairs and my whole bed," Rivera said.
The visitor looked out and saw a man wearing a green top and a white lab coat and saw that he had a rifle, she said.
Ruth Velazquez, an HIV counselor, said staff had trained for incidents such as this.
"We locked every single door in that place, every single door was locked, and we put the patients there, we made sure that our main concern was the patients," she said.
Hospitals have been the site of active shooting situations in recent years.
In January 2015, a patient's family member shot and killed
cardiac surgeon Michael Davidson before the shooter killed himself at Brigham and Women's Hospital in Boston.
And in Florida last July, a man entered a patient's room and opened fire
, killing an elderly female patient and a female hospital worker, police said. A suspect was taken into custody.