Witnesses said the suspect, identified as Raymond Martinez, 25, was selling CDs along Broadway and W. 45th street around 11 a.m. when two police officers asked him for a permit. The man fled, but turned and fired at cops about a block away when he reached the hotel.

A plainclothes sergeant from the NYPD’s anti-peddler unit then fired at the suspect, hitting him once in the chest. The suspect was taken to Roosevelt Hospital, where he later died.

Panicked pedestrians ran for cover as a police officer fired a shot and struck the gunman.

“I heard at least six shots,” said John Grisewood, 60, a tourist from London. “It happened about 10 or 15 feet away from me. The police officers were ducking and diving, trying to get out of the way. The police officers shot and dropped the guy.”

He said the suspect struggled with cops for several minutes before he was subdued.

Broken glass from one of the bullets littered the ground where the shooting took place.

“My wife yelled at me, `We need to get out of the way,'” Grisewood said. “She grabbed me and we went into a shop.

Police said the suspect had been using a Mac-10 and fired two rounds at police. There were 27 live rounds still in the gun.

He was carrying a card from a Virginia gun shop. The gun was reported stolen from Richmond, Va., on Oct. 28.

The suspect’s brother was also arrested when he tried to intervene after the shooting.

A friend of the suspect, who was also selling CDs, said the scene was chaotic.

“He wasn’t armed when I saw him,” said Mike Williams. “So I don’t know where the gun came from.”

He declined to give his friend’s name.

“I’m shocked that it went down like that,” Williams said. “He has a great personality, and if he did shoot at a cop I don’t condone that. This is Times Square. And a lot of people could have gotten hurt.”