WASHINGTON — A U.S. judge has ordered that Federal Reserve Chairman Ben Bernanke can be questioned in a lawsuit against the government filed by the former head of American International Group Inc.

It is rare for a Fed chairman to be deposed in a lawsuit. But Judge Thomas Wheeler of the U.S. Court of Federal Claims said Monday that he made an exception because Bernanke has firsthand knowledge of the government’s decision to bail out AIG at the height of the financial crisis.

Hank Greenberg, the former AIG CEO, has sued the government over the $182 billion bailout, which AIG has since repaid. Greenberg claims the terms of the bailout were too onerous and is seeking at least $25 billion.

“The court cannot fathom having to decide this multibillion-dollar claim without the testimony of such a key government decision maker,” Wheeler said in his ruling.

Greenberg’s attorneys want Bernanke deposed on Aug. 16. Wheeler said that date was acceptable to him, though lawyers for the government may wish to choose another date.

Former Treasury secretaries Henry Paulson and Timothy Geithner have agreed to give depositions in the case. Each played a key role in designing the bailouts.

The lawsuit was filed in November 2011 by Greenberg’s company Starr International, which was the largest AIG shareholder.

The lawsuit accuses the government of taking valuable assets from AIG’s shareholders without their consent or fair compensation, in exchange for the government’s 80 percent stake in the company. The government’s actions violated parts of the Fifth Amendment, the lawsuit contends.