The writer was chief economist and economic adviser to Vice President Biden from January 2009 to May 2011. He is a senior fellow at the Center on Budget and Policy Priorities.

The Troubled Assets Relief Program (TARP) worked a lot better, and at a much lower cost, than is commonly recognized.

TARP and related interventions by the Federal Reserve helped reactivate credit markets long before they would have recovered on their own, helped to stabilize the housing market, helped save the U.S. auto industry and helped prevent recession from morphing into something worse. And they did so for far less than early estimates and prior rescues had suggested were possible.

Saying that TARP worked — and that it might even ultimately turn a profit for the taxpayer — is not to say that stabilizing the financial system prevented the pain of the Great Recession. Millions of Americans continue to pay the price in long-term unemployment. Millions more have lost or will lose homes to foreclosure, and trillions of dollars in housing wealth have evaporated. The U.S. gross domestic product remains about $900 billion below its potential level. Unemployment remains stubbornly high.

The government’s financial-market interventions made that pain less deep, but they did not prevent it, and any potential gains from these programs pale next to the damage done by the high-finance-inflated bubble that caused the sharp downturn from which we’re still recovering.

With those caveats noted, here are the facts:

●Although the initial 2008 legislation set aside $700 billion for the program, by March 2011 the Congressional Budget Office estimated that TARP would disburse about $430 billion and get back all but about $19 billion.

A Treasury analysis published last week, using current market values, found that if the federal government were to cash out its remaining holdings, such as its stake in AIG, it would at least break even and probably turn a small profit. Market conditions could worsen, of course, but remember that official and media estimates of the cost of TARP ranged from the hundreds of billions to the trillions. The International Monetary Fund estimates that the average loss from 42 financial crises between 1970 and 2007 was 13 percent of GDP.

●Bank lending crashed along with the economy in late 2007. But banks began to ease lending standards as TARP was implemented, and accounting for the fact that underwriting is (thankfully) tighter than it was during the bubble, credit access is about back to pre-crisis levels.

●The housing market is, at best, bumping along the bottom. But here, too, the timing of home-price and sales stabilization coincided with TARP housing programs, including the rescue of Fannie Mae and Freddie Mac.

●Given credit conditions at the time, General Motors and Chrysler would have faced certain liquidation had not TARP rescued them. Post-restructuring, the industry has added 230,000 jobs, and sales are up 50 percent since 2009.

Of course, any profits from these measures are net of expected losses. We are unlikely to recover all of the investments in foreclosure prevention, Fannie, Freddie and the auto firms. But as the bank-lending program winds down, the Treasury is already ahead by $19 billion. Winding down the mortgage-backed-securities portfolio has yielded an additional $25 billion, and remittances from the Federal Reserve on profits from TARP-related lending have also been substantial.

This is all strangely circuitous. Government regulation of financial markets failed miserably, but government actions helped put out the fire, albeit after badly burning the economy. It’s hard to applaud the fire department when it abetted the arsonists.

Banks are recapitalized and less dependent on short-term funding, which makes them less vulnerable to the dynamics of the 2008 crash (the collapse of the overnight funds market was a major catalyst). But the Dodd-Frank financial reform law is far from implemented, and special interests are aggressively working to defang it. The arsonists have not left the scene.

To prevent them from starting the next fire requires strong implementation of at least three points of financial reform.

First, and most important, banks need larger capital cushions to sustain future losses without facing insolvency and bailout. Second, we need a strong Volcker rule to prevent commercial banks from speculating with deposits insured by taxpayers. Third, the Consumer Financial Protection Bureau is off to a strong start, but it needs to become a permanent part of the financial oversight landscape. Conservatives funded by the financial lobby haven’t given up their campaign to undercut the bureau, and its director is still a recess appointee.

The TARP-led financial rescue worked, and we should learn from its success. That said, the damage caused by the bursting bubble goes far beyond any expected profits from the bailouts. If our government doesn’t put in place the regulatory framework to deal with the inherent instability in financial markets, we’ll be back in the bailout business again before we know it.

Jared Bernstein, a former chief economist to Vice President Biden, is a senior fellow at the Center on Budget and Policy Priorities and author of “Crunch: Why Do I Feel So Squeezed?” among other books.