Hundreds of millions of dollars meant to provide a little relief to the nation’s struggling homeowners is being diverted to plug state budget gaps.

In a budget proposed this week, California joined more than a dozen states that want to help close gaping shortfalls using money paid by the nation’s biggest banks and earmarked for foreclosure prevention, investigations of financial fraud and blunting the ill effects of the housing crisis. California was awarded more than $400 million from the banks, and Gov. Jerry Brown has proposed using the bulk of that sum to pay the state’s debts.

The money was part of a national settlement valued at $25 billion and negotiated with five big banks over abuses in their mortgage and foreclosure processes.

The settlement, reached in February after a year of talks and intervention by the Obama administration, was the second-largest in history involving the states, trailing the tobacco industry settlement, and represented the first large-scale commitment by banks to provide direct aid to borrowers.