Goldman Sachs demanded billions of dollars in collateral from AIG to protect its customers, the Wall Street bank said on Thursday, defending itself against accusations that it contributed to the insurer's woes while padding its own profits.

But an American International Group official questioned Goldman's lack of flexibility in the 2007-2008 dispute over credit default insurance products linked to baskets of loans that included subprime mortgages.

Elias Habayeb said in testimony prepared for a U.S. panel exploring the origins of the financial crisis that AIG's counterparties would not cooperate during negotiations.

Not even the threat of bankruptcy by AIG or its financial products unit would extract discounts, he said.

Unfortunately AIG had little negotiating leverage, said Habayeb, who was chief financial officer of the firm's financial services division and has just returned to the company.

Habayeb is scheduled to appear alongside other former and current executives from AIG and Goldman, as the Financial Crisis Inquiry Commission continues its two-day-long hearing about the role of derivatives in the financial crisis.

Goldman Sachs has been dogged by criticism that it received a backdoor government bailout when taxpayer funds were funneled into an insolvent AIG, starting in September 2008, to help pay off counterparties like Goldman.

By March 2009, Goldman had received $12.9 billion of the $93 billion in money paid to AIG counterparties.

Ultimately, taxpayers pledged $182 billion in assistance to help AIG.

Goldman Chief Financial Officer David Viniar said in his prepared testimony that the firm's demands were for its customers, not Goldman itself.

He said Goldman's exposure to AIG was designed to help its customers manage their own risks.

Our net risk was consistent with our role as a market intermediary rather than a proprietary market participant, Viniar said.

Goldman's defense of its client focus comes as the firm is facing civil fraud charges from the U.S. Securities and Exchange Commission. The case filed in April alleges that Goldman misled investors in marketing a mortgage-linked financial product.

ACCOUNTING ACRIMONY

AIG and Goldman already aired portions of their collateral call dispute during the crisis commission's hearing on Wednesday.

The panel is examining the battle as part of its larger investigation of what caused the financial crisis that peaked in 2008, sending global markets reeling and U.S. unemployment skyrocketing.

The congressionally appointed panel is due to deliver its findings by December 15.

At the heart of AIG and Goldman's dispute is accounting.

Goldman and other counterparties to AIG's financial products unit marked the value of their exposure to fair market value -- what the underlying securities could currently fetch in the open market.

AIG, however, was valuing its related exposures on a longer-term horizon.

Once the housing market started its downward plunge in 2007, Goldman and other counterparties marked down the value of their exposures and demanded that AIG pay up collateral.

In late July of 2007 Goldman made a $1.8 billion demand to AIG. Goldman says AIG balked, in a dispute that lasted months until the government stepped in with its rescue.

Viniar said it was Goldman's vigorous commitment to accounting rules that forced it to pursue the big collateral calls.

He said the firm tried to work with AIG to agree on values for the financial products.

AIG's Habayeb, however, said its counterparties had little motivation to earnestly negotiate, because even if AIG went bankrupt the counterparties would get special protection under bankruptcy law.

AIG's efforts to stem the tide of collateral calls and reduce FP's risk exposure by negotiating with counterparties, including Goldman Sachs, during this period were largely unsuccessful, Habayeb said in his written testimony.

(Reporting by Karey Wutkowski; Editing by Tim Dobbyn)