The doctor who opened fire at Bronx-Lebanon Hospital Friday was searching for a former co-worker who he had promised to return and kill when he resigned in 2015 — but the employee had the day off.

Henry Bello, 45 — who resigned amid a sexual-harassment scandal — fatally shot a physician and wounded six other people with an assault rifle before killing himself, officials said.

“When he left he promised to come back and shoot one of the residents,” Dr. Maureen Kwankam told The Post about Bello.

“He said the resident will never graduate and become a doctor because he will kill him before he has the opportunity.”

Before he was canned, the deranged doc had threatened to harm at least four other people working at the hospital, Kwankam said.

He also called the resident once on the phone saying, “I’m gonna kill you,” sources said.

The resident, his intended target, was not working Friday.

Bello entered the hospital’s 16th floor looking for the resident when one physician noticed the AR-15 sticking out of his lab coat.

The doctor immediately started to run while screaming “Gun!” according to law-enforcement sources.

The gunman proceeded to shoot six people — three doctors, two med students and one patient — on the 16th floor. He then headed up one flight, where he fatally shot a 33-year-old doctor, the sources said.

When he was done shooting, Bello — who was carrying multiple jars of gasoline — set the 17th-floor nurse’s station on fire. The automatic sprinklers put the flames out.

Bello then barricaded himself in a room where he used the AM-15 rifle to shoot himself. He then crawled out to a hallway before dying where police also found the victim’s body nearby.

“There are several doctors who are fighting for their lives right now,” Mayor de Blasio said of the wounded victims. “Our hearts go out to the family of the doctor who passed away . . . This was a horrific situation unfolding in the middle of a place that people associate with care and comfort.”