A unit of Royal Bank of Scotland will pay $52 million (33.5 million pounds) to resolve allegations by the state of Massachusetts over its role in home loans that the state's attorney general called unfair.

The bulk of the settlement, $40.2 million, will be used to cut mortgage debt and provide other assistance to 700 subprime borrowers in the state.

Massachusetts Attorney General Martha Coakley said in a statement that RBS Financial Products Inc financed, purchased and securitized home loans that were presumptively unfair under Massachusetts law.

Under Massachusetts law, mortgage lenders have to determine if a borrower can repay a prospective loan under the terms of the contract, according to the complaint.

Many of the subprime loans were provided under the assumption that borrowers would later refinance when low initial rates increased.

The settlement also includes an $8.9 million payment to the state, and $2.6 million to compensate municipalities affected by foreclosures of loans the bank securitized.

The borrowers include those with risky loans securitized in 2006 and 2007.

While RBS did not make the loans itself, it funded the subprime lenders and purchased and securitized their loans.

We are pleased to have resolved this matter with the Massachusetts Attorney General, an RBS spokesman, Michael Geller, said in a statement.

The case is the third brought by Coakley against investment firms over home loans. Goldman Sachs agreed to a $60 million settlement in May 2009, and Morgan Stanley paid $102 million as part of a June 2010 settlement with her office.

(Reporting by Aruna Viswanatha in Washington D.C.; Editing by Derek Caney and Tim Dobbyn)