SANTA MONICA, Calif. — Four people were killed and five wounded on Friday morning as a gunman, dressed in black and carrying an assault rifle, strode across Santa Monica firing at people, cars, a public bus and buildings before being shot and killed by the police at the Santa Monica College Library, the authorities said.

The Santa Monica police at first said six people had been killed by the gunman. On Friday evening, Sgt. Richard Lewis said the actual figure was four. One of the victims was said to be in critical condition.

The shooting took place about 10 minutes away from where President Obama was attending a private fund-raising lunch before heading to Palm Springs for a meeting with the president of China. He went by motorcade to the Los Angeles airport and flew to Palm Springs about 2 p.m.