After months of delays, the San Francisco controller’s office announced Thursday that it expected the city to pay $4.4 billion to provide municipal retirees and their dependents with lifetime health benefits.

The city has set aside $9.7 million to cover the costs.

The estimate of San Francisco’s unmet health care liability has been closely watched by ratings agencies, labor unions and other groups concerned about the city’s long-term finances. Moody’s Investors Service downgraded San Francisco’s debt rating in November, citing the enormous retiree health-care obligations, among other factors.

In an interview, Benjamin Rosenfield, the city’s controller, said that the situation would be worse if the city had not enacted changes that went into effect last year. New city employees must pay 2 percent of their salary into a health care trust fund. Requirements to receive lifetime coverage were also tightened.

But Mr. Rosenfield said tens of thousands of employees are still entitled to lifetime coverage, and they pay nothing into the fund. “The bad news is the liability associated with the employees hired before” 2009 who contribute nothing, Mr. Rosenfield said.