PHOENIX — State lawmakers did nothing wrong when they seized $50 million out of the settlement Arizona got with mortgage lenders, a judge ruled today.

Maricopa County Superior Court Judge Mark Brain rejected arguments by housing advocacy advocates that the funds, part of a $26 billion nationwide deal, are supposed to be put into a special trust fund solely to help deal with mortgage fraud.

Brain acknowledged that Attorney General Tom Horne signed an agreement spelling out how the funds specifically going to the state are to be used. These permitted uses include "to avoid preventable foreclosures'' and to help prevent and prosecute financial fraud.

But the judge said that did not place the funds off limits to lawmakers.

"The Legislature had the right to do what it in fact did — direct $50 million of the settlement to be put into the general fund so that it could be spent as directed by the Legislature,'' Brain wrote.

Today's ruling is a setback for the advocacy groups which contended that the money is needed specifically to help homeowners who were the victims of mortgage fraud.