San Francisco may not be able to stop car break-ins or solve the homeless problem, but its finances are top-notch, according to Moody’s Investors Service, which raised its credit rating on the city’s general obligation bonds to Aaa on Tuesday.

It’s the first time in about 40 years that San Francisco has received the highest credit rating from any of the three major debt-rating agencies, according to Ben Rosenfield, the city’s controller. And San Francisco is the only large California city rated Aaa by Moody’s, although several California counties boast that rating. Of the 20 largest cities nationwide, seven others have an Aaa rating from Moody’s.

Moody’s analyst Lori Trevino attributed the rating bump to a combination of factors, including a booming economy and measures approved by voters and the Board of Supervisors to rein in and increase funding for pension and retiree health benefits and to bolster reserves.

The city’s rainy day reserves have risen to 9 percent of general fund revenues, from 1.4 percent of revenues at the bottom of the recession, Rosenfield said.

“The upgrade to Aaa reflects the material strengthening of San Francisco's credit, underscored by its effective management of pension and retiree health liabilities, particularly in contrast to other large cities,” Moody’s said in a statement. It also cited “long-term strengthening in the city's economy, tax base and socioeconomic profile.”

Moody’s previously had San Francisco rated one step lower, at Aa1. The other two rating agencies, Standard & Poor’s and Fitch, still have San Francisco at that level — one step below their highest, AAA rating. However, the city has asked them to review those ratings before it issues about $250 million in general obligation bonds in a couple of weeks. The voter-approved bonds will fund park and transit projects.

S&P on Monday raised its “outlook” on the city’s debt to positive from stable but left its rating unchanged. “We put the outlook on positive which means there is at least a 1-in-3 chance the rating will go up in the next couple years,” S&P analyst Chris Morgan said. “We want to see the degree to which there is continuity in the city’s budget approach as they transition to a new administration.”

In theory, a higher credit rating lowers the interest rate a city must pay on its debt, the same way a higher FICO score will usually get you a cheaper mortgage.

However, with interest rates so low, the difference between being rated Aa1 and Aaa is very small, said bond analyst Matt Fabian, a partner with Municipal Market Analytics.

“San Francisco’s bonds are already received as if they’re AAA or almost AAA, so the actual upgrade, in dollar terms, won’t have a material impact on borrowing costs,” Fabian said in an email. “This is better seen as a political shot in the arm for the mayor.”

In a statement, San Francisco Mayor Mark Farrell said the city is “justifiably being recognized for the efforts we have taken to become a national model of responsible fiscal governance. We are one of the only major cities in the country to approve comprehensive pension reform and retiree health care reform at the ballot box, and our City government has continually passed fiscally sustainable budgets.” He credited the mayor’s budget office, the controller’s office, the Board of Supervisors and the late Mayor Ed Lee.

Rosenfield called the upgrade “a comment on the city’s financial management and improvements we have made,” but “a significant part of it is just the strength of the economy and the tax base of the city.”

San Francisco’s property tax base grew more than 10 percent last year, by far the largest increase of any Bay Area county. “A lot of that is being driven by new construction,” he said. And “since the bottom of the recession, we have seen remarkable growth in the hotel tax. The city’s business taxes are benefiting from unemployment in San Francisco being under 3 percent.”