A child was among four people killed in a shooting at an office building in California that left a fifth victim and the gunman critically wounded, police said.

The violence in the city of Orange, southeast of Los Angeles, in the US, was the country's third mass shooting in just over two weeks.

When police arrived at the two-storey building at about 5.30pm on Wednesday, shots were being fired, police officer Jennifer Amat said.

Officers opened fire and the suspect was taken to hospital, Ms Amat said.

It is unclear whether the suspect suffered a self-inflicted wound or was shot by police.

Police provided no details on the victims other than to say one was a child and a woman was critically wounded.

In a tweet, California governor Gavin Newsom called the killings "horrifying and heartbreaking".

"Our hearts are with the families impacted by this terrible tragedy tonight," he wrote.

Ms Amat had no information about what may have prompted the attack.

She said the shooting occurred on both levels of the building.

Signs outside indicated a handful of businesses were located there, including an insurance office, a financial consulting firm, a legal services business and a phone repair shop.

People gathered outside the building after the shooting hoping to get word about loved ones.

Paul Tovar told KTLA-TV that his brother owns a business there, Unified Homes, a mobile home broker. "He's not answering his phone, neither's my niece," Mr Tovar said. "I'm pretty scared and worried - right now I'm just praying really hard."

Charlie Espinoza told The Orange County Register that he could not reach his fiance, who works for a medical billing company.

Cody Lev, who lives across the street from the office building, told the newspaper he heard three loud pops that were spaced out, then three more.

There was silence, then he heard numerous shots, followed by sirens and then more shots.

A Facebook livestream posted by a resident who lives near the office appeared to show officers carrying a motionless person from the building and officers providing aid to another person.

The killings follow a mass shooting at a supermarket in Boulder, Colorado, last week that left 10 dead.

A week before that six women were among eight people killed in three Atlanta-area spas.

The city of Orange is about 30 miles from Los Angeles and home to about 140,000 people.

Ms Amat said the shooting was the worst in the city since December 1997, when a gunman armed with an assault rifle attacked a California department of transportation maintenance yard.

Arturo Reyes Torres, 41, an equipment operator who had been fired six weeks earlier, killed four people and wounded others, including a police officer, before police killed him.