The unidentified man, who in video clips had short hair and wore jeans and a white tank top as he walked through the street, was pronounced dead at the scene, Los Angeles police Officer Cleon Joseph said. No officers were hurt.
Oscar Herrera, a witness, said he saw the gunman walking down the middle of Vine Street near Sunset Boulevard, firing at least nine shots into the air and at passing cars while shouting "kill me" and "I'm gonna die!"
"People were running all over," Herrera told KABC-TV. "People was ducking."
The 40-year-old male driver of a Mercedes-Benz was wounded in his upper body and taken to a hospital in unknown condition. A truck and another car were struck by bullets.
The gunman eventually ran out of ammunition and pulled a knife before a policeman fired at him four or five times, Herrera said.
Dave Pepper told KCAL-TV that he was in his car when the gunman attacked him.
"This guy came running across the street and he put the gun right up to this window," Pepper said as he sat in the car. "Why he didn't pull the trigger I don't know. ... I thought maybe he was out of bullets."
Investigators were trying to determine a motive for the attack. The area was cordoned off and the gunman lay under a white sheet in the street hours after the gunfire, leaving traffic tangled on busy Hollywood streets.
The area is packed with stores and restaurants, including the Cinerama Dome and Amoeba Records.
Some witnesses described the surreal incident as something that might have been staged on a movie location, a common sight around Los Angeles.
"When I heard it, I didn't react to it being real," said Greg Watkins, who was walking along the street when the shooting began.
"This is Hollywood, and they do film stuff all the time," Watkins told the Los Angeles Times. "I honestly thought they were filming something."