The U.S. Treasury said Wednesday it is close to turning a profit on direct bailout investments in the nation's banks, but still expects to post an overall loss in its financial bailout fund due to foreclosure prevention costs for homeowners.

Banks have repaid $243 billion of the $245 billion the government spent to support them directly, the U.S. Treasury said Wednesday. It eventually expects to post a $20 billion gain from its support directly to banks.

Treasury official Tim Massad said Wednesday that programs for direct support to banks will provide a profit for taxpayers.

However the $410 billion bailout fund known as the Troubled Asset Relief Program will see a $48 billion lifetime loss linked mostly to foreclosure prevention programs which were not intended to be recovered, the Treasury said.

The U.S. has recovered $274 billion overall until now.

Non-bank support from TARP has gone to bank insurer AIG, the U.S. auto industry and some initiatives to help credit markets.