STATEN ISLAND, N.Y. -- A “misunderstanding” between a landlord and one of the tenants in a Port Richmond apartment building escalated into a five-hour standoff with police, who were worried that a man was threatening two young children with a knife, according to NYPD sources.

The drama unfolded in a second-floor apartment at 945 Post Ave. at about 5 p.m. Sunday. According to NYPD sources, the building’s landlord was doing maintenance work inside a woman’s apartment, when her boyfriend rushed in, saying people were chasing him, looking to stab him.

That spurred the landlord’s wife, who heard screaming, to call 911, sources said.

A lengthy hostage negotiation scene followed — police cordoned off Post Avenue until after 10 p.m., as members of the NYPD’s Emergency Service Unit, Hostage Negotiation Team and Tactical Assistance Response Unit worked inside and outside the building.

An NYPD K-9 officer and his dog also stayed at the scene outside the apartment building.

According to NYPD sources, the situation might have been resolved in minutes if the woman living in the apartment had opened the door to show that her two young children were safe.

Police said as much to her, sources said, but the situation escalated — she refused, denying the man was inside.

Officers finally removed the door of the apartment, and found the man cowering in a child’s closet, sources said.

They took him and the woman into custody, sources said, though it’s not clear if the twp were going to be charged criminally or simply hospitalized as “emotionally disturbed persons.”

The children were unharmed, according to an NYPD spokesman. It’s not clear where they’re currently staying.

At about 10:30 p.m., an officer from the West Shore’s 121st Precinct stood sentinel outside the doorless apartment unit.