The NY police chief praises for the way his "brave" officers dealt with "a character running down the street, waving a cleaver".
The late-afternoon confrontation began when two uniformed officers found the suspect trying to remove a wheel clamp from a vehicle he appeared to be living in.
As the officers approached, Akram Joudeh, 32, pulled out the knife and ran, police said.
Officers shot with him with a Taser during the ensuing chase, but with little apparent effect.
A witness, Jonathan Schneier, said he saw the suspect holding the large blade.
He said he saw officers gathered around Joudeh, urging him to drop the weapon.
"I give credit to the police officers. They gave him many opportunities," Mr Schneier said.
The off-duty detective tried to tackle Joudeh as other officers chased him down a street, police said.
It was at that point that Joudeh wielded the knife, police said, slashing the detective's face.
Other officers then opened fire, discharging 18 shots and hitting Joudeh at least twice.
The detective was treated for a six-inch gash running from his temple to his jaw.
The shooting took place not far from Macy's department store and Madison Square Garden.
Police Commissioner William Bratton, who is retiring today, said the officers' response had been appropriate.
"We have a character running down the street, waving a cleaver," he said.
James O'Neill, who is succeeding Mr Bratton, said: "They shot until the threat was stopped."
Police said that in recent years, Joudeh had been arrested more than a dozen times, mostly for minor crimes.
The suspect's former neighbours in Queens told WNBC-TV that he appeared to be a troubled man who fought with his roommates, sometimes receiving visits from the police.