A Bronx man suspected in a series of hammer attacks in Manhattan was shot and critically wounded by police in midtown Wednesday morning after he attacked a female officer with a hammer, police said.

David Baril, 30, was shot three times after he attacked uniformed police Officer Lauren O'Rourke with a hammer at 10 a.m. at 37th Street and Eighth Avenue, said Chief William Aubry, head of detectives in Manhattan.

O'Rourke, 27, and her partner, Geraldo Casaigne, 38, recognized Baril from earlier wanted posters and were approaching to question him when the attack occurred, police said.

The encounter was captured on a police security video, which shows a man police identified as Baril appearing to watch the two officers as they walked quickly down Eighth Avenue.

The video shows Baril, who Aubry said wore a hood and a face mask, suddenly appearing to pull out the hammer and strike O'Rourke two or three times as he chased her through a busy intersection.

Casaigne, who began chasing the two, is then seen on the video holding his gun out and firing at Baril.

advertisement | advertise on newsday

Pedestrians nearby during the three-second confrontation are seen on the video cringing in fear and ducking for cover as the shots are fired.

Aubry said O'Rourke was struck by the hammer at least three times on the back of her body and suffered abrasions.

Casaigne's decision to fire at Baril likely saved O'Rourke's life, NYPD Commissioner William Bratton said. He also commended O'Rourke for having the presence of mind as she was being struck to call for backup on her radio.

"The officers acted professionally and heroically," Bratton said at a news conference outside the Midtown South Precinct, where O'Rourke and Casaigne work. "Officer Casaigne quite possibly saved the life of his partner."

O'Rourke and Casaigne were being treated at Bellevue Hospital Center and were expected to be released late Wednesday. Baril was listed in critical but stable condition at Bellevue.

Police believe Baril was responsible for four different hammer attacks in Union Square and midtown on Monday afternoon.

During those attacks, police said Baril screamed obscenities at his victims.

One high-ranking NYPD official said Baril's social media postings included anti-police and anti-white statements. In one Instagram post, Baril showed an image of a hammer with blood dripping from the head and claw, police said.

Baril had been diagnosed with paranoia and schizophrenia, Aubry said, adding that the conditions worsened when Baril didn't take his medication.

Baril has been arrested eight times, including once for an attempted assault on a police officer who was trying to serve him a summons in a Bronx park, Audry said.

advertisement | advertise on newsday

O'Rourke, who records indicate lives in Flushing, Queens, has been on the force for five years, while Casaigne, of Nassau County, has been with the NYPD for 11 years.

Jason Diakakis, 34, who lives near Casaigne, described him as a "stand-up guy" who always helps his neighbors.

"What he did today . . . he saved a life," Diakakis said. "To us, he's a hero."

With Maria Alvarez,

Kevin Deutsch and Alison Fox