Goldman Sachs has become the latest big bank to agree to a multibillion-dollar settlement over the way it packaged and sold mortgage-backed securities in the heady days of the housing boom.

The Justice Department said Monday that Goldman had agreed to pay $5.06 billion over its conduct in the packaging and sale of residential mortgage-backed securities between 2005 and 2007.

Investors lost billions of dollars during the period by purchasing securities based on mortgages that were often much riskier than they were presented to be.

"Today's settlement is another example of the department's resolve to hold accountable those whose illegal conduct resulted in the financial crisis of 2008," said Benjamin C. Mizer, head of the Justice Department's Civil Division. He added:

"Viewed in conjunction with the previous multibillion-dollar recoveries that the department has obtained for similar conduct, this settlement demonstrates the pervasiveness of the banking industry's fraudulent practices in selling RMBS, and the power of the Financial Institutions Reform, Recovery and Enforcement Act as a tool for combatting this type of wrongdoing."

Goldman had announced it January that it had tentatively agreed on a settlement.

U.S. officials say that as part of the settlement, Goldman agreed to a statement of facts about its handling of the securities. For example, although the firm originally stated that the loans underlying the securities were made in accordance with underwriting guidelines, that wasn't always the case, the statement said.

"Goldman received information indicating that, for certain loan pools, significant percentages of the loans reviewed did not conform to the representations made to investors about the pools of loans to be securitized," the Justice Department said.

U.S. officials also say Goldman's Mortgage Capital Committee was supposed to approve every mortgage-backed security issued by the firm but often failed to do so, even when other parts of the bank indicated some of the loans might be problematic.

In August 2006, one mortgage asset was found to have an "unusually high" percentage of loans with credit defects, according to a statement of facts.

"How do we know that we caught everything?" the committee asked.

"Depends on what you mean by everything? Because of the limited sampling ... we don't catch everything," a transaction manager responded. The committee went on to approve the security without requiring any more vetting, U.S. officials said.

Goldman also did not disclose to investors negative information it had received about the originators of the loans underlying its securities, U.S. officials say.

In 2006, Goldman marketed securities underwritten by loans that had been originated by Fremont Investment & Loan. It said Fremont, which was shut down by federal regulators shortly afterward, "had a commitment to loan quality over volume."

But a Goldman internal analysis had already concluded that many of Fremont's guidelines were "off market" or "at the aggressive end of market standards."

In the same year, Goldman was still packaging loans originated by Countrywide Financial Corp., even though it was aware of problems at the mortgage company.

When one company official circulated a bullish analyst report about Countrywide, Goldman's head of due diligence replied, "If they only knew ..."

The money Goldman will pay includes a $2.4 billion civil penalty, as well as $1.8 billion in relief to underwater homeowners, distressed borrowers and affected communities.

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