Police took a second heavily armed man into custody Thursday morning, several hours after the NYPD said his associate pointed a handgun at officers on Staten Island, who then shot and wounded the suspect.

The arrest of Jonathan Derbyshire, 24, followed a lengthy search that began shortly after 1 a.m. Thursday when officers shot Patrick Allen, also 24, multiple times, the NYPD said.

A uniformed NYPD sergeant and another officer were investigating a report of shots fired when they spotted the pair about 1:10 p.m. on Androvette Street near Arthur Kill Road, police said.

As the officers approached, NYPD officials said, Derbyshire took off into a nearby wooded area. Allen, clad in a heavy bullet-resistant vest, trained a 9-mm Glock 26 on the officers who then shot him three times in the leg and once in the arm, said NYPD Assistant Chief Edward Delatorre.

Allen was taken to Staten Island University Hospital in stable condition and investigators recovered the handgun at the scene, police said. Neither police officer was injured, officials said.

NYPD officers recovered an AR-15 semi-automatic rifle, a 9mm Glock 26 handgun and a ballistic vest after a shootout on Staten Island on Jan. 5, 2017. Photo Credit: NYPD

As officers searched the woods for Derbyshire — considered “armed and dangerous” — they recovered an AR-15 semi-automatic rifle and a hunting knife they suspect he dropped as he fled, police said.

advertisement | advertise on newsday

Investigators suspect Allen and Derbyshire left a house overnight and went into the woods to shoot.

“It appears at this time — it’s still under investigation — that they were hanging out in a house near the location and went out into the wooded area to test-fire some guns,” NYPD chief of patrol Terence Monahan told reporters Thursday after the swearing-in of a class of new recruits at the police academy.

A law enforcement source, who didn’t want to be named, said cops initially were concerned the 911 call that led the officers to the wooded area might have been a set up for an ambush. Investigators checked the call and determined it to be genuine.

NYPD Commissioner James P. O’Neill said detectives were trying to find out why the suspects were so heavily armed.

“They’re firing firearms within city limits. It’s very dangerous,” said O’Neill.

Allen and Derbyshire had what the source described as minor arrest records. Charges were pending against them.

This is the third police-involved shooting this week. Police fatally shot two men in separate incidents in Brooklyn on Tuesday night and early Wednesday morning.