San Francisco can collect millions of dollars in parking taxes from drivers who use University of California and state university lots in the city, the state Supreme Court ruled unanimously Thursday in a decision that applies to dozens of cities statewide.

University officials said the ruling could push up the price of parking on campuses.

Lower courts had ruled that UC San Francisco, UC Hastings College of the Law and San Francisco State University were exempt from the 25% tax because California law prohibits local regulation of state institutions. But the state’s high court said the tax is levied on drivers, not the universities, who face only the “minimal burden” of collecting the additional fees, a cost the city has agreed to pay.

“The law does not forbid a (local) government from imposing a tax on private third parties who happen to do business with another government,” Justice Leondra Kruger said in the 7-0 ruling. She said charter cities like San Francisco “may require state agencies to assist in the collection and remittance of local taxes.”

That applies to local hotel and utility taxes as well as parking taxes, said Deputy City Attorney Peter Keith, San Francisco’s lawyer in the case. Charter cities, which have more powers of self-government than other cities, total 121 in California and about 20 in the Bay Area, including San Francisco, Oakland and Berkeley.

“Everybody has to pay their fair share of taxes,” Keith said. He said users of UC and CSU parking lots “enjoy the city services just like people who park at any other garage in the city.”

The universities’ exemptions were costing San Francisco more than $4 million a year as of 2014, and that amount has increased because of the expansion of UCSF’s Mission Bay Medical Center, Keith said. The League of California Cities said in a court filing that parking taxes account for nearly 2% of revenue collected by cities in the state, and that the San Francisco case could benefit cities that host any of the 10 UC campuses or 23 CSU campuses.

The effect on drivers will be up to the universities, Keith said. If UC charges $10 for a parking place, he said, it could raise the rate to $12.50 to pass the 25% fee along to drivers, or it could absorb the cost by lowering its charge to $8 and leave the driver’s fee at $10.

UC said it was disappointed by the ruling.

“We are concerned that it may lead to increased costs for University of California students and employees, as well as patients at our medical centers, some of whom travel hundreds of miles for needed medical care,” the university said in a statement.

CSU told the court that a parking tax at SF State would make it difficult for the school to keep parking affordable.

San Francisco established its parking lot tax in 1970 and increased the rate to 25% in 1980.The city tried to collect the tax from UC San Francisco in 1983, backed off when the university objected, and finally sued in 2014 to require the schools to add the tax to their parking fees.

In 2017, the state’s First District Court of Appeal said the parking lots were exempt from local taxes because they were state “governmental activities” that supported the universities’ educational and clinical functions by providing access. The court cited a 1939 state Supreme Court ruling that said local governments cannot regulate state agencies.

In Thursday’s ruling, the court agreed that the Constitution prohibits one level of government from taxing another, but said the San Francisco tax was “not imposed on the state universities or their property,” only on drivers.

Kruger noted that a state appellate court in 1976 had upheld Berkeley’s tax on ticket sales at Oakland Raiders games at the UC Berkeley stadium.

“San Francisco has a legitimate interest in the millions of dollars in contested tax money, and a tax is effective only if it can be collected,” Kruger said.

The case is San Francisco vs. UC Regents, S242835.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @BobEgelko