(Bloomberg) -- The pandemic housing boom has pulled more than 1 million U.S. homeowners out of a debt trap that many had been stuck in since the great financial crisis more than a decade earlier.

The number of homes that are considered seriously underwater -- meaning that loans secured by the property are at least 25% higher than its market value -- dropped to 2.25 million in the second quarter, down from 3.5 million at the end of 2019, according to the latest home-equity report by real estate data firm Attom.

Chicago, Philadelphia and New York were among the urban areas that saw the biggest declines in the number of underwater homes.

The number of homes nationwide that are classified as “equity-rich,” meaning their value is at least double the outstanding loan balance, jumped by 4.2 million in the same period. They now account for 34.4% of all mortgaged properties, up from 26.7% at the end of 2019.

“Instead of the virus pandemic harming homeowners, it’s helped create conditions that have boosted the balance sheets of households all across the country,” said Todd Teta, chief product officer at Attom.

After the 2008 crash, borrowers across the country were left owning property that was worth much less than what they’d borrowed to buy it, leading to an extended foreclosure crisis in which millions of Americans were thrown out of their homes.

In the pandemic, the government imposed a moratorium on foreclosures. That measure expired on July 31, but the rapid increase in housing prices while it was in force means that many struggling homeowners may now be able to sell their property for a gain and avoid foreclosure. Median home prices nationwide were up 22% from a year earlier in the second quarter, according to Attom.

There remain pockets of the country where housing debt-traps are widespread. The major metro areas with the highest share of underwater mortgages include Baton Rouge (which topped the list at 12.7%) and New Orleans in Louisiana, and Toledo and Youngstown in Ohio.

At a more granular level, there are three zip codes in the Cleveland area where roughly half of all homes still have negative equity.

©2021 Bloomberg L.P.