Advocates for a public bank in San Francisco are rejoicing over Gov. Gavin Newsom signing legislation that will allow them to create a local institution to finance priorities like low-income housing, public infrastructure and small businesses.

Introduced by Assemblyman David Chiu, D-San Francisco, AB857 allows local governments to apply for a banking license for the first time. Newsom signed the legislation, which caps the initial number of public banks at 10, on Wednesday.

Public banks are financial institutions set up and operated by a local government. Support for them across the country swelled in the wake of the 2008 financial collapse, which multinational investment banks played a central role in creating. States and cities across the country are considering public banks, but North Dakota is the only state currently operating one.

Supporters have pushed San Francisco officials for years to consider municipal banks as an alternative to traditional commercial institutions, whose interests prioritize creating value for their shareholders over benefiting the communities where they do business. But setting up a public bank will be a complicated, time-consuming and expensive process — it could take the city 10 to 30 years to break even. But supporters are undeterred by the hurdles.

“We want to get as much of our city’s taxpayer dollars out of Wall Street so we can recapture that money to invest in our city,” said Jackie Fielder, co-founder of the San Francisco Public Bank Coalition. The coalition, she said, is “ecstatic” at the news that Newsom signed the bill.

“It’s about keeping our taxpayer dollars here in our city, in our region. That’s not happening right now because Wall Street is investing our money around the world into entities that we have no clue about how they fit into our priorities and addressing the crises here,” she said.

Chiu echoed that sentiment.

“Our public money should serve a public purpose and our local communities — not lining the pockets of Wall Street investors,” Chiu said. Municipal banks, he said, also allow local governments to avoid doing business with institutions that invest public money “in industries not in line with the values of most Californians,” like gun manufacturers, private prisons and the oil and gas industry.

Public banks could also be a boon to the legal cannabis industry. Marijuana’s status as an illegal drug under federal law has made most traditional banks reticent to do business with cannabis growers or retailers.

The idea has also enjoyed broad support among San Francisco officials. Former Supervisors John Avalos and Malia Cohen and current Supervisor Sandra Lee Fewer have backed the idea. But enthusiasm has waxed and waned, in part because of the staggering complexity and the potential costs.

San Francisco keeps about $100 million available to conduct business on any given day. Most of the city’s commercial banking is done with Bank of America and U.S. Bank.

Under the safeguards laid out in Chiu’s legislation, setting up a public bank will still take years, and any local government looking to do so will have to pass through a gamut of regulatory hurdles to prove to state regulators they can operate the bank — and protect the public’s money.

Still, backers of the idea say it’s well worth it. Public banks, they argue, could allow the city to provide financing for important projects and priorities that might be less attractive to commercial banks. Public banks would still have to turn a profit to stay solvent, but not nearly at the rate required by commercial institutions.

San Francisco Treasurer José Cisneros released a report in March to help suss out the complications and costs of setting up a public bank. The report was the culmination of nearly two years of work by a task force made up of financial experts, government officials and community organizations.

There are several models the report identified, each with varying degrees of complexity and both long- and short-term costs. Focusing just on lending for things like affordable housing and other community priorities would cost the city about $184 million over a decade — when the city could expect to break even. Divesting from Wall Street entirely would cost about $1.6 billion and take 31 years to break even.

Before San Francisco can apply to state regulators for a banking license, the Board of Supervisors must commission a feasibility study. Fewer said in a statement that her office is “actively exploring the next steps needed to realize our vision for municipal public banking.”

Not everyone is on board with the idea. The state legislation was opposed by the California Bankers Association, which argued Chiu’s bill would siphon money away from community banks and “potentially” put taxpayer dollars at risk.

“We remain opposed to the concept of public banks, and hope that community leaders and elected officials will take note of the risks associated with establishing a municipal bank, before opting to explore this unnecessary and unwanted public option,” the organization said in a statement.

Dominic Fracassa is a San Francisco Chronicle staff writer. Email: dfracassa@sfchronicle.com Twitter: @dominicfracassa