A man was graved by a bullet during an hours-long standoff with the NYPD overnight at an apartment in Queens.

NYPD officials said the situation began around 11 p.m. in Whitestone when a 911 caller reported a man acting “erratically” and harassing one of his employees.

Police responded to the business near 14th Avenue and 145th Place, where they watched surveillance video of the man appearing to hold a firearm,” Jerry Dowling, assistant chief of the emergency service unit, said at a press briefing Wednesday morning.

The responding officers then went around the corner to the man’s apartment and knocked on the door, attempting to engage him. Dowling said the man yelled at police and refused to let them inside.

Members of the emergency service unit arrived around midnight and tried talking to the man through the apartment door, according to the police account. After roughly 15 minutes, the man allegedly fired at officers through the door. At least one officer fired back, Dowling said.

A standoff between police and the man followed for about two hours, with the man repeatedly refusing orders to exit the apartment.

Dowling said police finally gained entry to the apartment after 2 a.m. and took the man into custody. He had a gunshot injury to his shoulder, apparently a graze wound.

The man, 57-year-old Orlando Montalvo, was taken to the hospital to be treated for his injury.

Police recovered four guns from the scene, all of which had the look of firearms but turned out to be “air guns,” Dowling said. He added that Montalvo, who had no mental health history with the department, had been convicted of second-degree murder in 1989 and released from prison in Dec. 2018.

The officers involved were also taken to a nearby hospital to be evaluated.