SACRAMENTO, Calif. (AP) - Three community assistance organizations sued Gov. Jerry Brown and other state officials on Friday, alleging the state improperly diverted nearly $370 million that was intended to help homeowners struggling with foreclosures.

The lawsuit filed in Sacramento County Superior Court says the money was siphoned off to the state’s general fund as California wrestled with a massive budget deficit and has never been repaid. The money was part of the $25 billion settlement between major banks and nearly every state in 2012, with California receiving the largest share.

H.D. Palmer, a spokesman for the Department of Finance, said in a statement that the administration is confident that its budget actions are legally sound.

The suit was filed by attorney Neil Barofsky, who previously was inspector general for the federal bank bailout. The suit alleges the money is needed to help affected homeowners “weather the economic storm that continues to sweep so many families out of their homes.”

“As a result of these diversions, large numbers of homeowners who are eligible for loan modifications or other relief have been left stranded, and countless fiscally imperiled California homeowners remain unaware of the full scope of their rights,” the lawsuit states.

Barofsky filed the suit on behalf of three California-based community organizations that the suit says have helped thousands of homeowners: National Asian American Coalition, COR Community Development Corporation and National Hispanic Christian Leadership Conference.

The suit says the state can now repay the money because it is projecting budget surpluses in coming years. It asks a judge to order that the state put the money into a special account to be administered by California Attorney General Kamala Harris.

Harris helped negotiate the national bank settlement and secure extra funding for California. She objected at the time to the money being used for other purposes, but spokesman Nick Pacilio declined to comment on the lawsuit.