It was the latest in a string of mass shootings in the United States in recent years. Most recently, the massacre of 17 people at a Florida high school has led to calls for tighter curbs on gun ownership.
Police did not identify the suspect or say what might have motivated Tuesday's shooting at YouTube, a video-sharing service owned by Alphabet Inc's Google which employs nearly 2,000 people at the San Bruno, California offices.
The woman approached an outdoor patio and dining courtyard on the campus around lunchtime and began to fire before entering the building, police said.
An affiliate of ABC and other local media, citing unnamed sources, identified the woman as Nasim Aghdam.
San Bruno police officials could not immediately be reached for comment on the identity of the attacker.
The website NasimeSabz.com, which media said was linked to the attacker, had several posts about Persian culture and veganism, interspersed with screeds against YouTube.
Those complaints included claims the company was not sharing enough revenue with people who create videos for the platform.
"There is no equal growth opportunity on YouTube, or any other video-sharing site, your channel will grow if they want to," read one posting on the site.
A YouTube account in the name of Nasime Sabz was deleted on Tuesday evening.
A U.S. government security official told Reuters there was no known connection to terrorism.
ABC News, citing unnamed law enforcement sources, said the suspect was 35 to 40 years old, and lived in Southern California.
A YouTube product manager, Todd Sherman, described on Twitter hearing people running, first thinking it was an earthquake before he was told that a person had a gun.
"At that point every new person I saw was a potential shooter. Someone else said that the person shot out the back doors and then shot themselves," Sherman said in a tweet.
Dozens of emergency vehicles quickly converged on the YouTube campus, and police could be seen on televised aerial video systematically frisking several employees leaving the area with their hands raised.
One victim, a 36-year-old man, was listed in critical condition at San Francisco General Hospital. A 32-year-old woman was listed in serious condition and a 27-year-old woman in fair condition. Authorities did not release names of the victims.
The three patients taken to San Francisco General Hospital were all awake, Dr. Andre Campbell, a trauma surgeon at the hospital, told a news conference. All were victims of gunshot wounds, Campbell said, but none of them had undergone surgery.
A fourth person was taken to a local hospital with an ankle injury from fleeing the scene.
"It's with great sadness that I tell you - based on the latest information - four people were injured in this horrific act of violence," Google Chief Executive Sundar Pichai said in letter to employees posted on Twitter.
"I know a lot of you are in shock right now. Over the coming days, we will continue to provide support to help everyone in our Google family heal from this unimaginable tragedy."
In a separate tweet, Pichai said he and YouTube Chief Executive Susan Wojcicki were "focused on supporting our employees and the @YouTube community through this difficult time together."
"Our thoughts and prayers are with everybody involved," Trump tweeted. "Thank you to our phenomenal law enforcement officers and first responders that are currently on the scene."
In response, Twitter Chief Executive Jack Dorsey tweeted: "We can't keep being reactive to this, thinking and praying it won't happen again at our schools, jobs, or our community spots. It's beyond time to evolve our policies."
Last month, YouTube announced it would ban content promoting the sale of guns and gun accessories, as well as videos that teach how to make guns.
Female mass shooters are rare. A recent Washington Post analysis shows only three of 150 U.S. shootings with more than four victims since 1966 were carried out by women. In 2015, a husband and wife killed 14 people in San Bernardino, California.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)
Election Results for Lok Sabha Election 2019 will be out on May 23. Get the latest election news and live updates on ndtv.com/elections. Catch all the action on NDTV Live. Like us on Facebook or follow us on Twitter and Instagram for news updates from each of the 543 parliamentary seats for the election 2019