The program, called Free Muni For Youth, was previously funded by the city at a cost of about $3 million per year; it allows more than 30,000 kids age 5 to 17 to ride San Francisco Municipal Railway buses and light-rail vehicles for free.
Before the announcement, Muni's board of directors was considering whether to keep the year-old program.
"With this unprecedented gift from Google, we can keep this successful pilot program running for at least two more years at no cost to taxpayers or Muni riders and free up critical funds for other vital Muni maintenance and services," Mayor Ed Lee said in a statement.
The donation couldn't come at a better time for Google, whose bus program has been a sore subject for residents in San Francisco.
"San Francisco residents are rightly frustrated that we don't pay more to use city bus stops," Google said in a statement to The Verge. "So we'll continue to work with the city on these fees, and in the meantime will fund Muni passes for low income students for the next two years."