Goldman Sachs will pay about $5 billion to resolve state and federal investigations into its handling of mortgage-backed securities in the years leading up to the 2008 financial crisis, the bank said today.

The agreement will settle "actual and potential civil claims" by the U.S. Justice Department and the attorneys general of New York and Illinois, as well as the Federal Home Loan Banks of Chicago and Seattle and the National Credit Union Administration, the firm said in a press release issued after the close of trading Thursday.

"We are pleased to have reached an agreement in principle to resolve these matters," said Lloyd C. Blankfein, Goldman's chairman and chief executive officer.

The firm said it will pay a civil monetary penalty of $2.385 billion, a cash payment of $875 million and $1.8 billion in consumer relief:

"The consumer relief will be in the form of principal forgiveness for underwater homeowners and distressed borrowers; financing for construction, rehabilitation and preservation of affordable housing; and support for debt restructuring, foreclosure prevention and housing quality improvement programs, as well as land banks."

Goldman said the settlement, an agreement in principle, has not yet been finalized by the parties involved. If it is, it will reduce earnings for the last three months of 2013 by $1.5 billion.

Ever since the subprime mortgage crisis upended the global financial system, authorities have been investigating a number of large financial institutions and their sale of mortgage-backed securities.

The investigations have centered on whether the banks misrepresented the real value of the assets.

Regulators have already won large multibillion-dollar settlements from several large banks, including JPMorgan Chase, Bank of America and Citigroup.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.