Bank of America Corp.'s financial-crisis hangover may finally be fading.

On Thursday, the bank agreed to pay $16.65 billion to settle the government's accusations it sold flawed mortgage securities in the run up to the 2008 crisis, the largest settlement ever reached between the U.S. and a single company.

For the U.S. government, the deal...