Goldman Sachs Group Inc completed the long-awaited sale of its mortgage servicing unit on Thursday after having reached agreements with the Federal Reserve and New York state's banking regulator over wrongful foreclosures.

In a deal with New York Financial Services Superintendent Benjamin Lawsky announced Thursday morning, Goldman agreed to forgive 25 percent of principal balances for struggling homeowners who are 60 days past due on mortgage payments, at a cost of $53 million. It will also compensate some home loan borrowers for wrongful foreclosures, at an indeterminate cost.

Separately the Fed ordered Goldman to hire a consultant to review foreclosures performed in 2009 to 2010 by Litton Loan Servicing LP, a mortgage-servicing business the bank sold to Ocwen Financial Corp for $264 million on Thursday.

The review is meant to identify borrowers who were wrongly foreclosed and the Fed said it believes a monetary penalty will be necessary.

Goldman shares were down 3.1 percent at $112.61 in afternoon trading after the Fed agreement was announced. Ocwen Financial was down 2.7 percent at $13.43.

While the sale of Litton would seem to close a troubled chapter for Goldman, both deals the bank struck with regulators indicate that it is not yet off the hook.

Lawsky's deal with the bank does not preclude any future investigations of past practices or release any future claims or actions whatsoever, the state agency said in a statement.

Litton's regulatory troubles stem largely from the practice of robosigning, in which bank employees signed foreclosure documents without reviewing case files as required by law. Many large banks, including Bank of America Corp, JPMorgan Chase & Co, Wells Fargo & Co and Citigroup Inc, have been targets of probes by state and federal regulators over the same issue.

In the deal with New York, Goldman, Litton and Ocwen agreed to stop the robosigning practice, institute new staffing and training requirements for employees handling foreclosures and withdraw pending foreclosure actions that are based on faulty paperwork.

They also agreed to compensate borrowers for wrongful foreclosures and strengthen protections for homeowners in relation to late payment fees and insurance costs.

In return, Lawsky agreed to issue a no objection letter to the planned Litton-Ocwen transaction.

Goldman bought Litton in 2007 for $430 million, hoping to glean more information about the subprime mortgage market to help its trading business. But more recently, it has become a money-losing thorn in Goldman's side.

The bank began considering a sale of Litton late last year, as the mortgage market continued to suffer losses and state and federal regulators began investigating industry-wide foreclosure problems. Goldman wrote down the value of the business by $220 million in the first quarter.

In a quarterly filing on August 9, Goldman said Litton was facing probes by state attorneys general and banking regulators. A group of the nation's largest banks are said to be working toward a settlement that could resolve some of those investigations and cost the industry billions of dollars.

Ocwen is now the 12th largest mortgage-servicer in the United States after having acquired Litton, a relatively small player in the industry.

(Additional reporting by Sakthi Prasad in Bangalore; Editing by Vinu Pilakkott, Robert MacMillan and Steve Orlofsky)