FORMER FEDERAL Reserve Board chairman Ben S. Bernanke found himself facing tough questioning in a federal courtroom last week, and he seemed “none too pleased about it,” as the Wall Street Journal put it. Mr. Bernanke’s interrogator was a lawyer for Maurice R. “Hank” Greenberg, the former chief executive (and a major shareholder) of insurance giant AIG, who is suing the U.S. government on the grounds that its 2008 bailout of the firm violated his constitutional rights. Mr. Bernanke has said that the rescue of AIG, which ultimately involved $182 billion in government commitments, was a necessary evil that he and the Bush administration undertook only because AIG’s collapse would have imperiled the world economy. By his apparent demeanor in the courtroom, Mr. Bernanke communicated annoyance at Mr. Greenberg’s attempt to punish this good deed — and we don’t blame him.

The AIG bailout was not only especially onerous for the government — and U.S. taxpayers — but also especially galling. AIG got into trouble by recklessly extending its guarantee to securities backed by sketchy subprime mortgages. Amid the panic of September 2008, it appeared headed for a bankruptcy that might be even more epic than the collapse of Lehman Brothers. Unwilling to risk that, Mr. Bernanke, then-Treasury Secretary Henry M. Paulson and New York Federal Reserve president Timothy F. Geithner crafted a financial lifeline for the company, swallowing their contempt for its irresponsibility. In the process, AIG’s creditors also got bailed out, including many European banks whose approach to risk wasn’t much more admirable than AIG’s.

That “back-door bailout” may forever be debated, but we believe history will vindicate the AIG rescue. Despite fears that the company was too big and too complex to unwind without massive taxpayer losses, the Obama administration, taking over from the Bush administration, managed to achieve just that. It wasn’t a free lunch, in the sense that advancing AIG federal resources that might have been used elsewhere implies a cost to taxpayers even if the money got paid back. But the bailout was a lot better than the alternatives that faced Mr. Bernanke and his colleagues in that grim time.

Now comes Mr. Greenberg to complain, in essence, that the government ripped him and other stockholders off by failing to negotiate more generous terms when it took nearly 80 percent equity in the firm, diluting their stakes — in violation, Mr. Greenberg also argues, of the stockholders’ express objections. It was all unnecessary, he claims, because the company was merely illiquid, not insolvent, and could have been saved with a loan.

To be sure, Mr. Greenberg was no longer in charge of AIG when it engaged in its riskiest financial engineering. Otherwise, though, his claim of victimization has nothing going for it. The U.S. government had ample legal authority to bail out AIG in the public interest and no time to debate the illiquid/insolvent distinction or to haggle over price. Mr. Greenberg’s beef ignores one very large point: His shares would have been worth zero if the firm went under. His indignant demand for billions of dollars in compensation now illustrates why so many Americans have lost faith in the financial sector.