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.

Image Jeffrey T. Johnson. Credit... NBC, NY

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.