Santa Monica Police Chief Jacqueline Seabrooks told reporters the rampage began at a house in the coastal city before the gunman, dressed all in black, made his way to Santa Monica College.
Seabrooks said he killed two people in the house, which caught fire, two more people as he moved several blocks toward the campus, and then two more on campus.
He entered the library and fired on other people but didn't hit them, Seabrooks said.
Several students in the library reported hearing gunfire, and one witness said he heard a woman scream.
"The officers came in and directly engaged the suspect and he was shot and killed on the scene," Seabrooks said.
She identified the gunman as 25 to 30 years old and dressed all in black, wearing what appeared to be a ballistic jacket.
The campus was searched for a second shooter, and a man dressed entirely in black, with the words "Life is a Gamble" on the back of his sweatshirt, was seen being taken into custody by law enforcement officers. He did not appear to be wounded.
"We are not convinced 100 percent that the suspect who was killed operated in a solo or alone capacity," Seabrooks said.
All of this unfolded about 3 miles from where President Barack Obama was attending a fundraising luncheon.
Three women with gunshot wounds were admitted to Ronald Reagan UCLA Medical Center, said Dr. Marshall Morgan, the chief of emergency medicine. One died, another was in surgery, and the third was in serious condition but doing well, he said.
Three other women went to UCLA Medical Center Santa Monica with relatively minor injuries, Morgan said. One has shrapnel-type injuries and the two others had injuries not related to gunfire, he said.
Jeff Furrows of the Santa Monica Fire Department said there was extensive fire damage inside the home where two bodies were found, and one of the wounded women was found with a gunshot wound in a car nearby.
Jerry Cunningham Rathner, who lives near the house, said she heard gunshots and came out onto her porch to see a man shooting at the residence. Soon, the building erupted in flames and was billowing smoke.
The gunman, dressed in black and wearing an ammunition belt, went to the corner and pointed a rifle at a woman in a car and told her to pull over, Rathner said. He then signaled to a second car, also driven by a woman, to slow down and began firing into the vehicle.
"He fired three to four shots into the car — boom, boom, boom, right at her," said Cunningham, who went to the woman's aid and saw she was wounded in the shoulder.
"I can't believe she didn't have worse injuries," Cunningham said.
She said the gunman then abducted the woman in the first car and drove away.
From there, the scene shifted to Santa Monica College, located in a neighborhood of strip malls and homes more than a mile inland from the city's famous Santa Monica Pier, Third Street Promenade and its expansive, sandy beaches.
Jimes Gillespie, 20, told The Associated Press he was in the college's library studying when he heard gunfire, and he and dozens of other students began fleeing the three-story building.
"As I was running down the stairs I saw one of the gunmen," said Gillespie, who described the shooter as a white man in his 20s, wearing cornrows in his hair and black overalls. He said the man was carrying a shotgun.
Gillespie believed there were two shooters because he heard two kinds of gunfire — a shotgun and a handgun — but only saw one person.
"The shotgun blast was first. It was either him or the partner who shot eight to 10 handgun shots," Gillespie said. "Then after I saw the gunman I heard more shots and I ran out of the library through the emergency exit."
As Gillespie ran across campus, he said he saw a car in front of the English building that was riddled with bullet holes, had shattered windows and a baby's car seat in the back.
Another student, Khwanfa Wilepananon, said he and a friend were on the library's third floor when they heard a loud bang and a woman's scream coming from the first floor. As he and a friend fled downstairs, he said they heard two shots.
"It was so scary," said Wilepananon. "It was so dark and I was scared. We didn't know what to do."
Santa Monica police Sgt. Rudy Flores said numerous witnesses called to report that the shooting near the college began with a man on a street corner near the college firing shots at vehicles, including a bus.
California Highway Patrol Officer Vince Ramirez said his agency began receiving 911 calls just minutes before noon.
"We understand one shooter was taken into custody shortly after we arrived," he said.
The two-year college, with about 34,000 students, was in the midst of final exams Friday. It was quickly locked down by police, and students were told to leave.
As the drama unfolded, Obama was attending a fundraising luncheon about 3 miles away.
Secret Service spokesman Max Milien said the agency was aware of the shooting but it had no impact on the president's event.