Police said the rampage ended when the suspect, identified as Dung Trinh, 43, of Anaheim, was grabbed by people inside the hospital and held until police arrived. A gun was recovered.
Authorities said Trinh was apparently angry at the West Anaheim Medical Center over the death of his mother at another hospital earlier that day.
Mot Trinh, 72, had been treated at West Anaheim Medical Center in June for an undisclosed illness. She was taken to Anaheim Memorial West Hospital early Tuesday and died about five hours later.
After her death at about 10:30 a.m., police Lt. Steven Walker said Trinh drove a few blocks to West Anaheim Medical Center, where he shot three people.
A witness said one of the three was shot once when he tried to close the doors to a lobby and twice more when he struggled with the gunman.
"That's when I grabbed my children and we ran out," said Faith Perry. "I'd just like to thank him and say God bless him for what he tried to do for us," she said.
Hospital personnel captured the suspect after he opened around 11 a.m., reports CBS Station KCBS-TV in Los Angeles. According to KCBS, the suspect went to the second floor of the building, shot an employee, then went to the first floor and shot another worker before being captured.
Police identified the victims as Marlene Mustaffa, 60, of Buena Park; Vincent Rosetti, 51, of Seal Beach; and Ronald Robertson, 51, of Fullerton. All worked at the hospital.
Two of the victims died where they fell. The third died a short time later in the hospital's emergency room.
Police said it appears the gunman fired off numerous rounds before he was disarmed, although they wouldn't say how many. The shootings occurred on two different floors.
About three hours after the shootings, police checking a pickup truck believed to belong to the assailant suddenly closed a parking lot and asked the Orange County bomb squad to send an explosive-detecting dog to the scene.
As the investigation continued, worried relatives of employees and patients waited impatiently behind yellow crime-scene tape strung across the hospital's entrances.