LOS ANGELES (AP) — Lenders took possession of fewer U.S. homes in 2012 than a year earlier, as the pace of new homes entering the path to foreclosure slowed and banks increasingly opted to allow troubled borrowers to sell their homes for less than what they owed on their mortgage.

All told, banks repossessed 671,251 homes last year, down nearly 17 percent from 804,423 the year before, according to data released Thursday by foreclosure listing firm RealtyTrac Inc.

The trend, along with an annual decline in overall foreclosure activity, suggests that the country’s foreclosure woes are easing, at least on a national level.

But half the states experienced higher levels of foreclosure activity last year and many are expected to continue seeing increases this year, RealtyTrac said.

All told, foreclosure activity, defined as the number of homes that received at least one foreclosure-related filing, declined 3 percent last year. That translates to 1.8 million U.S. homes, and represents a drop of 36 percent from a peak of 2.9 million homes in 2010, the firm said.

Florida had the nation’s highest foreclosure rate last year, with 3.1 percent of households, or one in 32, receiving a foreclosure-related filing during the year.

Generally, states such as Florida and New York, where the courts play a role in the foreclosure process, take longer to work through their cases than California, Utah and other so-called nonjudicial states with a more streamlined process.

The judicial states also have taken longer to work through a backlog of cases that built up in 2011 when foreclosure processing slowed as the mortgage industry addressed allegations that lenders had processed foreclosures without verifying documents.

As a result, foreclosure activity rose last year in 25 states, most of them states with a judicial foreclosure system, while it declined in 25 others, most of those being non-judicial foreclosure states, RealtyTrac said.

Among the states with the biggest increases were New Jersey, Florida and Illinois. States with the biggest annual decline in foreclosure activity included Nevada, Utah and Arizona.

Many of the states with a judicial foreclosure process, including Florida, Illinois, Ohio and Indiana, should be caught up with their foreclosure backlog halfway through this year, said Daren Blomquist, a vice president at RealtyTrac.

Other states, such as New York and New Jersey, where the foreclosure process can run an average nearly three years, will continue to play catch-up through most of 2013, he added.

Blomquist expects foreclosure activity will decline in non-judicial foreclosure states through the first half of the year. But laws passed last year in California, Oregon and Nevada aimed at making it more difficult for lenders to foreclose on homeowners may end up deferring foreclosures in those states until later in the year.

“That could mean that, although we are comfortably past the peak of the foreclosure problem nationally, 2013 is likely to be book-ended by two discrete jumps in foreclosure activity,” Blomquist said.

While foreclosure activity declined last year, the inventory of homes in some stage of foreclosure or in banks’ possession climbed 9 percent to 1.5 million homes, RealtyTrac said.

Florida accounted for the biggest share of foreclosure inventory last year, or 20 percent of the national total.

Blomquist forecasts that between 500,000 and 600,000 homes will end up being repossessed by banks nationally this year, noting that, historically, about half of all homes that enter the foreclosure process end up being taken back by lenders. Last year, 1.1 million homes got started on the path to foreclosure.