By Laila Kearney

NEW YORK (Reuters) - A man accused of a string of hammer attacks in tourist-packed areas of New York City earlier this week was shot on Wednesday after he swung the tool at a police officer on a city street, police said.

Two uniformed New York police officers approached 30-year-old David Baril in Midtown Manhattan because he matched the description of the suspect in earlier hammer assaults.

"When he turned around, he pulled out the hammer and violently started swinging the hammer at the female officer," Deputy Chief William Aubry told reporters.

The other officer then fired four shots at Baril, striking him in the arm, torso and head areas, police said.

Baril was seriously wounded and is being treated at Bellevue Hospital Center.

Police Chief Bill Bratton commended the quick action of the male officer who preliminary evidence showed "quite possibly saved his partner's life by shooting the suspect."

The female officer was being treated for abrasions at a hospital.

Baril is accused of four separate attacks, all on Monday, in which he used a hammer to strike people on the head. Police initially said there were three attacks.

In one instance, a man with a hammer struck a 28-year-old Manhattan woman in Union Square Park, police said. [ID:nL1N0Y31V4] About 10 minutes later, also in Lower Manhattan, a 33-year-old woman who was walking with her boyfriend was hit in the back of the head, authorities said. The suspect fled.

While investigating those assaults, police learned of a third attack earlier in the day in Midtown Manhattan in which a 20-year-old man was hit on the head with a hammer while crossing a street, police said. A fourth attack was later reported.

The victims were all treated for scalp injuries.

Baril has been arrested eight times before, once for attempting to assault a police officer, Aubry said. In May of last year, Baril posted a photo to his social media account of a bloody hammer believed to be the same one used in the recent attacks, he said.

He suffers from paranoid schizophrenia and his condition worsens when he does not take prescribed medication, Aubry said, adding that police were working with the office of the New York City District Attorney to bring charges against Baril.

(Reporting by Laila Kearney in New York; Writing by Eric M. Johnson; Editing by Eric Walsh; Editing by Cynthia Johnston, Emily Stephenson, Bill Trott and Eric Walsh)