Goldman Sachs said Thursday it will pay roughly $5 billion to settle federal and state probes of its role in the sale of shoddy mortgages in the years leading to the housing bubble and subsequent financial crisis.

Coming nearly eight years after the crisis, the settlement is by far the largest the investment bank has reached related to its role in the meltdown. But the payment is dwarfed by those made by some of its Wall Street counterparts.