A mortgage lender participating in New Jersey’s foreclosure mediation program may not unilaterally modify the terms of a mediated settlement designed to keep the homeowner in his or her home, the state Supreme Court ruled on Monday.

In a unanimous ruling, the court found that a lender, GMAC Mortgage LLC, violated the terms of the judiciary’s Residential Mortgage Foreclosure Mediation Program when it repeatedly modified the terms of an agreement it had reached with one of its borrowers—who eventually lost her home even though she never agreed to the modifications.

Justice Barry Albin said a trial court and an appeals court erred in ruling in GMAC’s favor.

The case was remanded to the Chancery Division in Monmouth County to fashion a remedy, but the justices acknowledged that the defendant, Tamilynn Willoughby, may not be able to return to the home if it has already been sold in good faith to another buyer.

The judiciary created the foreclosure mediation program in 2008 in the wake of the mortgage collapse. The program is intended to allow tens of thousands of New Jersey homeowners to avoid foreclosure if they enter into mediation with their lenders and agree to modified mortgage terms.

According to the decision, Willoughby and GMAC entered into a modified agreement in 2010, but GMAC unilaterally modified the terms of the agreement at least four times over the course of the next three years without Willoughby’s consent. GMAC eventually bought Willoughby’s Union Beach home—which she initially purchased with a $183,000 mortgage—for $100 at a sheriff’s sale in November 2013, the ruling said.

Albin said the program is designed to promote finality once an agreement has been reached, and to avoid “endless rounds” of mediation and litigation.

“This appeal illustrates one case that eluded the beneficent purposes of the program,” Albin said.

The court agreed with the Seton Hall University Law Center for Social Justice that GMAC’s actions in repeatedly modifying the terms of the 2010 agreement violated the public policy of the program.

Albin said GMAC entered into an enforceable agreement in 2010, and added that the agreement, though never marked as “final,” was never meant to be interpreted as a “placeholder” agreement that it could modify later without Willoughby’s consent.

“Willoughby has endured years of litigation, ending with the loss of her home,” Albin said. “She is entitled to the benefits of the agreement for which she had bargained. The program’s salutary goals can only be met if our chancery courts enforce mediated settlements.

“Willoughby carried out her part of the bargain,” Albin said.

The most equitable solution would be for Willoughby to get her home back, but Albin said that would not be possible if it has already been purchased in good faith by another buyer. He suggested that part of an equitable award could include the $58,790 Willoughby paid to GMAC after the 2010 agreement, plus $132,682 GMAC obtained in insurance coverage for damage caused to the house by Hurricane Sandy in 2012 that Willoughby never received.

Both Willoughby’s attorney, Joshua Denbeaux of Denbeaux and Denbeaux in Westwood, and GMAC’s lawyer, Andrew Zacharda of Newark’s Tompkins, McGuire, Wachenfeld & Barry, were away from their offices and unavailable for comment.