When the tourists and shoppers thronging Times Square on Saturday afternoon first saw the police officers, guns drawn, confronting a knife-wielding man, many thought they had stumbled onto a movie set.

But it was quickly apparent this was no celluloid fantasy.

As the man fled, weaving through crowds and darting between cars, he threatened bystanders, witnesses said. The police gave chase, eventually cornering him near 37th Street and Seventh Avenue and killing him in a fusillade of bullets after, police officials said, he ignored orders to drop his weapon and lunged at officers.

Paul J. Browne, the chief police spokesman, said officers used pepper spray six times to try to halt the man, who repeatedly threatened officers with a kitchen knife with a six-inch blade.

“He continued to advance on uniformed officers, refusing officers’ repeated commands to drop his weapon,” Mr. Browne said. “Two officers discharged their weapons at close quarters on Seventh Avenue between 37th and 38th Streets.”