The sidewalks in Midtown Manhattan were swarming with the morning crush of office workers, and crowds of tourists were already pushing their way into one of the world’s most famous buildings. Around the corner, in the shadow of the Empire State Building, stood a 58-year-old man wearing a suit and carrying a black canvas bag. Inside the bag, the police said, was a .45-caliber semiautomatic handgun.

The man, Jeffrey T. Johnson, lurked behind a van parked outside the drab office building that houses the apparel importer that had laid him off almost two years ago. When Mr. Johnson spotted Steven Ercolino, a sales executive at the company who was on his way to work, he made his move.

Mr. Johnson, an office rival of Mr. Ercolino’s who the police said held Mr. Ercolino responsible for the loss of his job, pulled out the gun, fired at Mr. Ercolino five times, put the gun away and calmly walked off, trying to blend into the crowd as Mr. Ercolino lay bleeding on the sidewalk.

Mr. Johnson turned the corner onto Fifth Avenue. A few feet ahead were the shiny front doors of the Empire State Building — and two police officers who had been alerted to the shooting by a construction worker.

From about eight feet away, the officers confronted Mr. Johnson and when he pulled out his gun, they opened fire, shooting a total of 16 rounds. Mr. Johnson was killed and nine bystanders were wounded, perhaps all by police bullets.

The gunfire echoed outside one of New York’s must-see tourist destinations, where visitors were already riding the elevators to the observation decks nearly a quarter-mile up. Suddenly, on the streets below, there was pandemonium: Frightened passers-by were dashing into nearby stores and diving behind racks of merchandise. Construction workers were running for cover. Passengers on buses rumbling down Fifth Avenue were yelling, “Get down, get down.”

“It was like nothing I’d ever heard in my life,” said Joseph Cohen, 27, who was buying coffee in a fast-food restaurant across Fifth Avenue from the Empire State Building. He said he assumed “it was balloons popping or something” until he saw the commotion on Fifth Avenue — and Mr. Johnson’s body lying on the sidewalk.

Of those hit or grazed by bullets, eight were New Yorkers, their ages ranging from 21 to 56. The ninth was a 35-year-old woman from Chapel Hill, N.C. They were taken to NewYork-Presbyterian/Weill Cornell hospital and Bellevue Hospital Center, where officials said their wounds were not life-threatening. Six of the nine had been treated and released by Friday night, the police said.

The Police Department’s chief spokesman, Paul J. Browne, said one witness had told investigators that Mr. Johnson had fired at the two officers, “but we don’t have ballistics to support that.” Mr. Browne said “it’s possible” that the officers had shot him before he could return fire.

One officer fired seven times, the other nine times, Mr. Browne said.

Mr. Johnson, 58, and Mr. Ercolino, 41, had a long history of antagonism. They had scuffled in an elevator in April 2011, after Mr. Johnson lost his job at the company. They took their grievance to the Midtown South police station, arriving within 15 minutes of each other, Mr. Browne said. He said that Mr. Johnson claimed Mr. Ercolino had threatened him and that Mr. Ercolino claimed Mr. Johnson had threatened him.

Mr. Ercolino was shot at 9:03 a.m. and Mr. Johnson “minutes later,” Mr. Browne said.

Witnesses said that as Mr. Johnson stepped out from behind a van parked in front of the building where Hazan Imports has its office, at 10 West 33rd Street, he gave no indication of what was about to unfold.

One witness, Darrin Deleuil, said he saw Mr. Ercolino fall to the ground and rushed over to help him up, not realizing he had been shot. “A guy with a briefcase just came and just stood right over him and just kept shooting him — boom, boom, boom,” Mr. Deleuil said.

“He looked right at me,” he said, but never turned the gun on him. “He wanted every bullet for that guy.”

Read more