A new law in California enacts sweeping changes in pension benefits for state and local government employees. The law, billed as the biggest rollback to public pension benefits in the state’s history, is aimed at repairing a pension system that is at least $165 billion underfunded, according to The Associated Press (AP).

The measure increases the retirement age for new employees, caps the annual payout at $132,120 and requires workers who are not contributing half their retirement costs to pay more. The changes apply to the state’s two main pension funds, the California Public Employees’ Retirement System (CalPERS) and the California State Teachers’ Retirement System (CalSTRS).

The measure affects the state and most local governments, many of which participate in the state’s pension programs. Officials with CalPERS and CalSTRS said the changes would save between $65 billion and $78 billion over 30 years for the two programs.

Most state workers already contribute half their pension costs. The law requires another 75,000 state workers to also contribute 50 percent of pension costs within the next two years.

 All new employees starting Jan. 1 will automatically contribute 50 percent of their pension costs. For current local government workers, labor unions have a five-year window to negotiate pension contributions. If no deal is reached by Jan. 1, 2018, a city or school district can require employees to pay half their pension costs.

The measure is a compromise between Democratic and Republican state legislators. Moody’s Investors Service said the legislation could boost California’s credit outlook.