The state Public Utilities Commission voted unanimously in favor of those rules and others for such companies as Lyft and Sidecar. Both companies rely on smartphone applications to connect riders and drivers who use their own vehicles.
Commissioners said the rules were needed to ensure public safety.
"Today, we have an opportunity to introduce groundbreaking regulation in the transportation industry," commission President Michael Peevey said before the vote.
The regulations put ride-hailing firms in a new category of business called transportation network companies that are separate from taxi cabs and limousines.
In addition to training, criminal background and insurance requirements, the companies will have to implement a zero-tolerance policy on drugs and alcohol and ensure vehicles undergo a thorough inspection.
The founders of Sidecar and Lyft applauded the commission's decision.
Sidecar founder Sunil Paul said it helps make his company and others like it "mainstream" by giving them a legal permit to operate.
Lyft co-founder John Zimmer echoed those sentiments, saying the new category helps legitimize car-sharing companies.
"It provides clarity in the marketplace and in the community and authorizes the operations we've been doing for the last 14 months," Zimmer said.
The companies, additionally, said they already meet some of the new rules, including the background checks and commercial insurance requirements.
The vote came amid debate over how government should regulate the burgeoning "sharing economy."
New businesses using the Internet are trying to make it easy for people to share their property, be it cars or houses, and earn some money. But they face opposition from traditional service providers that complain about being undercut.
Commissioners heard from numerous taxi cab drivers and owners before the vote.
"This is not real ride-sharing," said Hansu Kim, president of San Francisco-based DeSoto Cab Co. "This is a commercial business that venture capital is backing, and the rules for commercial vehicles need to apply. That is the bottom line."
Supporters of ride-sharing companies said they fill the gap left by a dearth of taxis, which are often hard to find on the streets of San Francisco.
Commissioner Michel Florio said he has found some people rely solely on taxis, while others only use companies such as Sidecar and Lyft.
"People have different preferences and different needs. This decision allows both to take place on what I think is a fair basis," he said.