A San Francisco power outage that stranded people in elevators and left tens of thousands of others in the dark Friday was caused by the massive failure of a circuit breaker that sparked a fire at a power substation, a utility company spokesman said.

Pacific Gas & Electric posted online just after 5 p.m. that power had been restored to all the 90,000 customers who lost it in the Financial District and other areas of the city. Spokesman Barry Anderson said the equipment failed before a planned repair.

The Fire Department tweeted that it had responded to more than 100 calls for service, including 20 stuck elevators with people inside. At hospitals, surgeries were disrupted briefly but no problems were reported because backup generators kicked in, Mayor Ed Lee said.

"The best news of all was no injuries were associated with this incident," Fire Chief Joanne Hayes-White said.

No traffic collisions were reported, either, and officials thanked motorists for driving so cautiously during the blackout. In fact, people in the city of 850,000 people were generally courteous to each another.

The city's iconic cable cars were taken out of service as a precaution since streetlights were not operating on large parts of their routes.

Tourists weren't griping, though, said spokeswoman Erica Kato. "Everyone's very understanding — it's not us," she said.

The outage initially closed the Bay Area Rapid Transit agency's downtown Montgomery Station. People used the lights of their cellphones to walk through the darkened station before service was restored.

Later, people milled on sidewalks, controllers directed traffic manually, and shops were dark. Some buildings had power, others did not. ATM screens were blank and the city's famed cable cars were shut down for hours.

People were confused about what was going on and what to do, said Pam Martinez, a 25-year-old San Francisco resident and software engineer who was on a train when she heard the announcement that her destination station was closed.

"Even crossing the street was chaotic because the streetlights don't work and there's a few ambulances trying to go through the crowds," Martinez said. "It's pretty crazy."

Patricio Herrera sat glumly in his darkened restaurant, Ziggy's Burgers, at what should have been a busy lunch hour full of people hungry for his freshly ground hamburgers.

"We have lost everything today," said Herrera, the store's consulting chef and manager. Six employees sat at tables behind him, chatting or checking their phones.

Employees at a Starbucks gave away cups of iced and hot coffee in the darkened shop. A worker said that was better than letting the coffee go to waste.

Many of those affected used social media to vent their frustrations or post celebratory memes about getting off work early to play. Police Chief William Scott said officers were working to clear traffic as quickly as possible, but in the meantime folks should just relax.

"Take advantage of this beautiful day. See the city and enjoy the restaurants, enjoy the parks and whatnot until we get traffic back to normalcy," he said.

For some, that was easier said than done.

Brent Chapman, who works in billing and reporting for First Republic Bank, told his team to go home after huddling on a sidewalk and waiting for word of when power would be restored.

They had been ready to send out a finished project Friday, one they'd been working on for six months, after some had pulled an all-nighter.

"It's brutal. This is seriously the worst possible time that this could have happened," Chapman said. "I do not want to leave. I want to stay and get this done."

Anderson said the substation that failed was set to be part of $100 million upgrade of the power system.

AP reporters Kristin J. Bender, Jocelyn Gecker and Juliet Williams contributed to this story in San Francisco and John Antczak and Amanda Lee Myers from Los Angeles.