The hammer-wielding suspect believed to have attacked four strangers within a span of six hours in Manhattan earlier this week was shot in midtown Wednesday after attacking an NYPD officer with the weapon on the street, authorities said, and the chilling altercation was caught on video.

The suspect, an image of whom had been captured by surveillance cameras and released by police Tuesday, was shot near West 37th Street and Eighth Avenue around 10 a.m. Authorities identified him as 30-year-old David Baril, whose last known address was in the Bronx; he has a history of mental illness, including paranoia and schizophrenia, and a lengthy criminal record.

Dramatic video of the confrontation shows the uniformed officers approach the suspect, wearing a hood and mask, from across the street. The suspect lunges at 27-year-old officer Lauren O'Rourke with a hammer, claw side facing out. He chases O'Rourke into the middle of the road and repeatedly hits her over the head with the hammer as she falls to the ground. Officer Geraldo Casaigne, 36, follows his colleague and the suspect into the street, weapon drawn, and fires.

Casaigne fired four shots at Baril, and the suspect was hit at least three times -- in the head, arm and torso, NYPD Deputy Chief Will Aubry said at a news briefing Wednesday. Police and multiple sources initially said Baril was dead, though police later said he was taken to Bellevue Hospital in extremely critical condition. He underwent surgery there and remained in critical condition later Wednesday.

O'Rourke, who has been assigned to Midtown South since 2009, and Casaigne, assigned to the same precinct since 2003, were in the area responding to a call about an unrelated assault when they recognized Baril from the surveillance images obtained Tuesday and followed him, Aubry said. Aubry said at some point the suspect apparently realized he was being followed, and attacked the cops.

A white-claw hammer similar to the one described in the series of attacks Monday was recovered at the scene. Aubry said investigators looking into Baril's history spotted a photo that appeared to be of the same hammer on his Facebook page in May 2014. The hammer in that photo was bloody.

NYPD Commissioner Bill Bratton said O'Rourke was treated at a hospital for abrasions to her upper shoulder area; she underwent a CAT scan at the request of doctors concerned about any potential injuries from the hammer. Bratton said authorities were awaiting the results of that test. Casaigne was not injured in the fray; he was taken to a hospital for evaluation as a precaution.



Both officers were expected to be released from the hospital later Wednesday.

"These officers acted professionally and heroically this morning," Bratton said, adding that Casaigne likely saved O'Rourke's life.

Authorities had been looking for Baril after identifying him Tuesday through facial recognition, an NYPD source said. The suspect has eight prior arrests, including for assault, weapons possession and drug possession, police said. One of the attacks involved an assault on a police officer; in another, he jumped a counter at a fast-food restaurant. Baril voluntarily left a mental health facility in December and has had no recent address, authorities said.

Police believe Baril has been living in parks and subways since he left the facility, and frequented the area near Union Square, where he allegedly attacked two women with a hammer in separate ambushes within minutes of each other Monday. NBC 4 New York first reported Tuesday that authorities believed he was behind two similar attacks that occurred in Manhattan earlier that day.

All four victims were attacked in Manhattan within a span of five hours, police said. The first, around 1:45 p.m., involved a 20-year-old man in Herald Square; Baril yelled profanities at the man before hitting him with the hammer, then ran off, Aubry said. The victim refused medical attention.

About three hours later, police say the same suspect swung a hammer at the head of a 34-year-old woman in Madison Square Park, near 27th Street and Madison Avenue.

The attacks near Union Square unfolded in a span of 10 minutes between 7:36 p.m. and 7:46 p.m. One of those victims, a 28-year-old woman, was sitting on a bench in the park when she saw the suspect looking at her, police said. When she made eye contact, he took a silver hammer out of his bag and struck her, according to police.

The other woman attacked in that short time span, who is 33, was walking on West 17th Street between Fifth and Sixth avenues when the stranger approached her from behind and hit her in the back of the head with the hammer, police said.

The woman on West 17th Street was taken to a hospital with a scalp injury, authorities said. Both women attacked near Union Square were treated at Lenox Hill Hospital and released Monday.

The NYPD said it was working with the district attorney's office to determine what charges should be filed against Baril. Authorities said he has not been linked to additional attacks at this time, but they ask that anyone who feels they may have been victimized by him to contact police.

Nick Cearley, who said he was on the corner of Eighth Avenue and 37th Street at the time of the shooting Wednesday, said he heard gunshots and ran for cover. In an email, he called the experience "one of the scariest and terrifying mornings in NYC to date."

Thomas Vasicak was walking by Eighth Avenue when he saw the suspect go after the female NYPD officer; he heard shots ring out and "got out of the way" because he didn't know what was happening. Bystanders screamed and pointed toward the bloodied suspect on the pavement.

"I heard the shots and I saw the guy go down. I saw the guy go down and they're screaming, 'That's the guy with the hammer,'" Vasicak said.

Other witnesses said they abandoned their coffees at bodegas and left their partially-eaten breakfasts in diners as they fled the sound of gunshots.

Anina Boise, who saw the suspect on the ground after he was shot, found the situation unsettling.

"When I heard the story I was scared about it because I'm in Union Square all the time, and I had no idea he was in my neighborhood where I work," she said.

Baril's most recent address in the Bronx has no phone number.