The nation’s five largest banks and a consortium of state attorneys general are closing in on finalizing a settlement of at least $25 billion for the roles the banks played in the mortgage meltdown, POLITICO has confirmed.

If completed, the deal would be the largest of its kind in history, rivaling the 1998 settlement states reached with the tobacco industry, and the largest civil action ever against the housing industry. The agreement would cap a year-long series of negotiations designed to hold banks accountable for falsifying documents related to home foreclosures in several states.

Under the proposed terms, mortgage debt would be cut for about 1 million homeowners, while another 300,000 would have their loans re-financed at lower interest rates. Roughly 750,000 who were foreclosed on would each be compensated for their loss with $2,000.

More than two million Americans could benefit from the settlement, according to a source familiar with the negotiations.

But it won’t exempt the banks from all liabilities: Government officials would still be able to investigate potential crimes connected to the housing bubble, in addition to investigating mortgage industry practices such as bundling sub-prime mortgages into bonds, the source said.

The bulk of the settlement would be set aside for struggling homeowners, including loan modifications, refinancing and principal reduction — rewriting the mortgage to reflect the current value of the home. Another portion of the money would fund a reserve account for state and federal programs and for payments to homeowners whose mortgages were improperly processed.

The consortium effort between the Justice Department and the 50 state attorneys general, led by Iowa Attorney General Tom Miller, has been looking to strike the deal with Bank of America, Citigroup, JPMorgan Chase, Ally Financial and Wells Fargo.

A deal had been widely anticipated at several points, but hit snags as several attorneys general — including Eric Schneiderman of New York, Kamala Harris of California and Beau Biden of Delaware, son of Vice President Joe Biden — raised concerns that the proposal was too small and would grant the banks immunity from possible prosecution for fraud. On Monday night, the Huffington Post, citing sources, reported that Harris and Biden agreed to join the settlement.

Others expressing reservations had included the attorneys general of Minnesota, Nevada, Massachusetts and Kentucky.

The pressure to strike a deal had produced an intense backlash from liberals last summer. But several moves appeared to change the mood, including President Barack Obama’s creation of a new mortgage crisis unit headed by Schneiderman, announced in his Jan. 24 State of the Union address. That unit is working with the Consumer Financial Protection Bureau.

Obama signaled that he intended to move aggressively against banks and lenders via the new unit, with Schneiderman leading the investigation into whether banks committed fraud by issuing risky subprime mortgages and reselling them as securities on Wall Street.

In a recent MSNBC interview, Schneiderman said the initial proposed settlement “has a lot of good stuff in it,” but he objected to the banks’ request for immunity from prosecution in exchange.

“I drew a hard line — there’s absolutely no way I will join you if you give these guys a release from other conduct that hasn’t even been investigated yet,” Schneiderman said. “I was absolutely adamant that you do not release [the banks] from claims for the conduct that blew up the economy.”

In naming him to the task force, “the president has been absolutely clear: We’re going after the stuff that blew up the economy,” Schneiderman told MSNBC’s Chris Hayes. “We’re going after the possibilities of tax fraud, insurance fraud, securities fraud. We’re going to look at this stuff very carefully.”

Schneiderman’s office declined comment on the current negotiations.

The settlement is a critical step in sorting out a housing mess that many industry economists say won’t return to normal until 2015. Fannie Mae chief economist Doug Duncan projects that home prices nationwide could drop by as much as 7 percent this year, a serious drag on the economic recovery.

The amount of homeowners helped by the deal would still represent a fraction of the estimated 14 million borrowers who would benefit from a refinancing plan outlined last month by academics including Glen Hubbard, dean of the Columbia University School of Business and an adviser to Mitt Romney’s presidential campaign.

Even with the settlement, uncertainties about the housing market still remain. Few lawmakers and lobbyists expect to resolve the status of Fannie Mae and Freddie Mac, the mortgage giants the government took control of when the mortgage crisis boiled over in 2008.

But there are significant political considerations in play, since the crisis is at its worst in three major swing states: Florida, Michigan and Nevada — and the foreclosure rates are also high in battlegrounds Michigan, Virginia, North Carolina and Indiana.