The government’s much-maligned bank bailout program, approved by Congress during the throes of the financial crisis in late 2008, officially turned a profit for taxpayers on Wednesday.

The Troubled Assets Relief Program, or TARP, was the government’s most high-profile attempt at stabilizing the crumbling financial system. Treasury invested $245 billion into hundreds of the nation’s banks in recent years. With a series of repayments this week, $251 billion has now been returned to government coffers, the agency said in a release Wednesday.

“While our overriding objective with TARP was to break the back of the financial crisis and save American jobs, the fact that our investment in banks has also delivered a significant profit for taxpayers is a welcome development,” Treasury Secretary Timothy F. Geithner said in a statement. “We still have more work to do repairing the damage caused by the crisis and strengthening the recovery, but today is an important milestone in our efforts to recover taxpayer dollars as we continue winding down TARP.”

The bank investments make up only one element of TARP, which included more than a dozen programs and was used in the bailouts of automakers General Motors and Chrysler, the rescue of American International Group and the Treasury’s key foreclosure mitigation effort.

Treasury officials said Wednesday that based on current market conditions, they expect TARP investments as a whole to result in “little or no cost” to taxpayers.

“That’s a significant mark. It means that taxpayers will not lose money on the banks,” said Linus Wilson, an assistant professor of finance at the University of Louisiana at Lafayette who has analyzed TARP data. “That doesn’t mean all the banks are doing great; in fact, many of them are not doing great.”

Wilson noted that 164 small banks and credit unions that had received TARP funds — nearly a quarter of those that got aid — missed their most recent TARP repayments. He also said that despite TARP’s positive results, it had posted far lower returns than private investors who made similar investments.

One of TARP’s harsher critics remains Neil Barofsky, the outgoing special inspector general for the program. He has disparaged the handling of the lack of transparency and the handling of TARP, particularly the Home Affordable Modification Program, or HAMP.

“It fulfilled its promises to Wall Street, as reflected in the return to record profitability of the nation’s largest banks,” Barofsky said in his testimony on Capitol Hill this week. “But unfortunately, it’s failed to live up to some of its promise to Main Street.”

Barofsky often has warned that TARP could leave a legacy of “moral hazard,” meaning that financial firms might take more risk in the future if they think the government will step in during a crisis.

Despite that assessment, Treasury officials have remained adamant that the controversial program was necessary and that the profits it has reaped are a result of prudent management.

“TARP was necessary, and it did what it was supposed to do,” Tim Massad, acting assistant secretary for Financial Stability, said on Capitol Hill this week. “Its most significant legacy is that it, combined with other government actions, helped save our economy from a catastrophic collapse and may have helped prevent a second Great Depression.”