BOSTON (AP) — Massachusetts Gov. Deval Patrick has given final approval to legislation that seeks to prevent home foreclosures by forcing mortgage lenders to offer modifications on certain “risky” loans.

Patrick signed the bill Friday afternoon. It had passed unanimously in both chambers of the Legislature.

READ MORE: Patriots still don't have offensive play-caller to replace Josh McDaniels

The governor said the legislation creates “unparalleled consumer protections” and ensures that mortgage borrowers are given every chance to stay in their homes.

READ MORE: 168-year-old Peterboro Basket Co. in NH closing, citing forest pest

It requires lenders to assess a borrower’s circumstances and determine whether the net value in changing an existing loan is more than the anticipated recovery from foreclosure. If so, the lender is required to offer a loan modification to the borrower.

It also prohibits lenders from foreclosing on properties without proper documentation and includes provisions to create a task force to study mediation programs.

MORE NEWS: 'Stigma free zone,' National Alliance on Mental Illness brings back fundraising walk this Saturday in Boston

Copyright 2012 The Associated Press