Fannie Mae and Freddie Mac were sued by Massachusetts for allegedly failing to comply with a state law that lets nonprofit organizations buy foreclosed homes to sell them back to their former homeowners.

Massachusetts Attorney General Martha Coakley today sued the two government-backed finance companies and the Federal Housing Finance Agency, the U.S. regulator that oversees them, in a bid to force them to comply with the state law, passed in August 2012.

Fannie Mae and Freddie Mac require nonprofits that buy foreclosed homes and resell them to their former owners to pay the full amount of the mortgages or the properties' fair market value, whichever is higher, according to a complaint filed today in state court in Boston. That policy runs afoul of a state law that allows a foreclosed-home purchase at the lesser price, Coakley said.

"It makes no sense for our federal government to stand in the way of this work to help struggling families stay in their homes, and it is illegal for Fannie and Freddie to do this in Massachusetts," Coakley said in a statement.

The challenged policies interfere with efforts by groups such as Boston Community Capital, which has prevented 475 Massachusetts families from being displaced since it was started in 2009, according to the complaint.

Corinne Russell, a spokeswoman for the housing-finance agency; Andrew Wilson, a spokesman for Washington-based Fannie Mae; and Brad German, a spokesman for Freddie Mac, declined to comment on the suit.

Bloomberg News