MIDTOWN, Manhattan — A man wielding a meat cleaver was shot by police after attacking officers near Penn Station Thursday during rush hour, police said.

The attack happened just before 5 p.m. in the area of West 32nd Street, between Sixth and Seventh avenues in midtown.

Police said two uniformed officers responded to a report of a man removing a boot from a vehicle that he was apparently living in. They encountered Akram Joudeh, 32, who pulled out an 11-inch meat cleaver from his waistband then ran away, police said.

The officers chased after Joudeh, with one of them deploying a stun gun that appeared to have no effect on the suspect.

As the suspect reached Seventh Avenue, an off-duty detective in civilian clothes on his way home trying to take down Joudeh. The detective was struck in the head by the meat cleaver and suffered a gash from his temple to jaw, authorities said.

Uniformed officers then fired about 18 rounds at the suspect, hitting him several times. The detective and suspect were rushed to a hospital where the detective is listed in serious condition and the suspect in critical but stable condition.

Two other officers suffered non-life threatening injuries during the encounter.

A large police presence was visible in the area just as rush hour began. Throngs of pedestrians were seen on the sidewalks lined with police tape and surrounded by marked NYPD cars.

"I want to commend them for their performance," NYPD Police Commissioner William Bratton said. "We have a character running down the street, waving a cleaver. Despite that, the officers approached him, started to take him into custody during which one of them received significant injuries to his face. At which time, based on preliminary investigation, officers fired sufficient rounds to stop the attack. I want to commend them for their bravery and performance of duty."

Joudeh has a lengthy criminal past with 11 previous arrests, including criminal possession of a weapon, criminal mischief and operating a vehicle while impaired by drugs charges, police said.