WASHINGTON – Treasury Secretary Timothy Geithner stood before staff members at a recent town hall meeting and offered a eulogy for the government’s $700 billion bank bailout program, which is set to expire today, two turbulent years after Congress approved it during the heat of the financial crisis.

He understood as well as anyone the paradox that the Troubled Assets Relief Program, or TARP, has come to represent: Economists largely agree that the massive federal bailouts beginning in 2008 saved the country from a financial abyss.

But rarely has a government program become so widely reviled, so stigmatized, that even lawmakers who voted for it avoid the subject.

Geithner acknowledged that most Americans remain “rightfully angry” at seeing their government bail out the financial firms whose recklessness sent the housing market into a tailspin, triggered a wave of unemployment and wreaked havoc on the economy.

And then he offered the full-throated defense of TARP that he and other officials have repeated often in the wake of the financial crisis, an insistence that he and his predecessors made hard but courageous choices.

“It wasn’t fair,” he said of the bailouts. “But it was necessary.”

Indeed, most experts agree that the government’s quick and massive bailouts of some of the country’s biggest financial firms and automakers — from Citigroup to General Motors to insurance giant American International Group — prevented a far worse outcome.

Despite initial fears that taxpayers could lose hundreds of billions of dollars, the estimated cost of TARP has decreased steadily as banks have repaid bailout money and as the Treasury has received interest and dividend payments on its investments and sold stakes in companies it helped rescue.

But it hasn’t been all roses and high-fives.

For starters, TARP represented only a fraction of what the government spent to save the financial system. The Treasury and the Federal Reserve alone have committed more than $1.5 trillion to prop up the faltering mortgage and housing markets.

The bailouts left the federal government deeply involved in the private sector, an unprecedented and uncomfortable marriage that has stoked anger and resentment on all sides.

TARP’s detractors — even watchdogs overseeing it — have criticized officials for poor management, a lack of transparency, and even for altering the original approach of buying troubled assets. They also note the program’s glaring failure in combating foreclosures.

every measure, TARP remains hated by a public that views it as little more than a rescue of the rich Wall Street titans who caused the crisis.

That deep-seated resentment has factored into the anti-Washington, anti-incumbent sentiment so prominent in this year’s midterm elections, in which a yes vote on TARP has proven to be its own toxic asset.

After today, the Treasury no longer will be able to launch initiatives using the money, though some programs will continue to operate for years.

According to the special inspector general overseeing the fund, seven of the 13 aid programs that make up TARP had closed or were winding down as of June 30. Of the $700 billion approved by Congress, the Treasury has handed out less than $400 billion.

“I know across the country Americans will rejoice in its demise,” Geithner said. “TARP was something our country should never have had to do. … But for all the baggage, there is something to embrace about TARP.”

But the biggest cost of TARP might not become clear for years — and it might not involve dollars and cents.

“Unless the programs’s effectiveness can be convincingly demonstrated, the government will not authorize similar policy responses in the future,” members of the bipartisan Congressional Oversight Panel wrote in their most recent report. “Thus, the greatest consequence of the TARP may be that the government has lost some of its ability to respond to financial crises.”