NEW YORK — Bank of America and Wells Fargo both topped Wall Street expectations for the third quarter Thursday.

Wells Fargo’s third-quarter earnings were up 59% after it freed up money it had set aside to cover loan losses.

The bank said it reduced the money it set aside to cover loan losses by $1.7 billion. It had raised those loan loss reserves early in 2020, when the future of the economy and the length of the recession brought on by Covid-19 pandemic was uncertain.

The bank posted net income of $5.1 billion, or $1.17 a share, topping forecasts of 98 cents from analysts surveyed by Refinitiv.

“The actions we’re taking to improve operating effectiveness and financial returns are coming through in our results, in addition to the benefits we’re experiencing from the economic recovery,” said CEO Charlie Scharf.

In the second quarter of 2020, Wells Fargo raised the reserves it had set aside for loan losses by $8.4 billion, which caused the bank to post its first quarterly loss since the Great Recession at that time.

Scharf was brought in as CEO at Wells Fargo two years ago to deal with the scandal of the bank creating false customer accounts and improperly charging them fees. He is the fourth CEO since the fall of 2016.

He’s had some success. A 2018 consent order with the Consumer Financial Protection Bureau regarding the bank’s retail sales practices was recently allowed to expire, an event that Scharf described as “an important milestone in our progress to correct our past practices.” But that doesn’t mean its regulatory problems are behind it.

The Office of the Comptroller of the Currency, the Treasury Department’s banking regulator, slapped it with a $250 million fine in September for failing to move fast enough to compensate customers who were victims of the bank’s “unsafe or unsound” practices.

“The recent OCC enforcement actions are a reminder that the significant deficiencies that existed when I arrived must remain our top priority,” said Scharf. “I believe we are making significant progress, and I remain confident in our ability to continue to close the remaining gaps over the next several years, though we may continue to have setbacks along the way.”

Bank of America results

Bank of America said net income rose 58% to $7.26 billion, or 85 cents a share. That topped the estimates of Wall Street analysts who were looking for earning per share of 70 cents, according to FactSet.

The average estimate of seven analysts surveyed by Zacks Investment Research was for earnings of 71 cents per share.

The nation’s second-largest bank posted revenue of $24.01 billion in the period. Its revenue net of interest expense was $22.77 billion, also surpassing Street forecasts. Four analysts surveyed by Zacks expected $21.73 billion.

Bank of America shares have increased 42% since the beginning of the year, while the S&P’s 500 index has increased 16%. The stock has increased 73% in the last 12 months.

Both banks benefitted from being able to reverse some funds set aside early in the pandemic in case of loan defaults. Wells Fargo said the move boosted earnings by 30 cents per share.