Federal Reserve

Chairman Ben Bernanke said Tuesday that no other bailout has made him "angrier" than that of insurance giant

American International Group

(AIG) - Get Report

, but he added that the mammoth rescue plan was necessary to prevent mass chaos in the financial markets.

Before the Senate Budget Committee on Tuesday, Bernanke explained that

AIG's

collapse would have hurt not only the insurer, but its counterparties, competitors, the broad markets and taxpayers. If the firm failed, he said, it would have cost the global financial markets "trillions of dollars" and the government probably would not have recovered its massive investment.

The Treasury Department announced a new $30 billion credit facility for

AIG

on Monday as the company reported the biggest loss on record for any company.

AIG

had already received up to $150 billion in government support, and the Fed and Treasury eased terms on repayments to keep the struggling firm afloat.

But during a tense questioning session in which Congress members launched harsh questions criticizing the bailout plan, Bernanke said that "nothing has made me angrier" than the way AIG operated before the emergency rescue. He characterized the firm as one that used regulatory loopholes to operate as a full financial services firm with hedge-fund qualities, rather than a plain-vanilla insurer.

But he still defended the Treasury and Fed's efforts to stabilize the financial markets, noting that inaction, or a weaker, less comprehensive rescue of major financial institutions, would have extended the financial crisis longer and cost taxpayers more.

When asked by a senator whether the U.S. will have a long, drawn-out recession similar to that of Japan in the 1990s, he assured legislators that this would not be the case.

"The Japanese mistake was not acting quickly enough or aggressively enough," said Bernanke, "and that's not our problem."