The bankruptcy settlement helped Ally Financial — run by CEO Michael Carpenter—save a fortune, according to a special examiner’s report. (Getty Images)

Bankrupt ResCap could have won nearly $1 billion more if it had sued parent Ally Financial instead of settling its claims, an independent examiner found.

The 2,235-page previously sealed report from special examiner Arthur Gonzalez found that ResCap had $3.1 billion in legitimate claims against Ally.

ResCap ended up settling with Ally for $2.1 billion — winning bankruptcy-court approval for the deal just hours before the report was released yesterday.

However, some sources close to the bankruptcy process believe that ResCap creditors who have not signed on to the settlement may still press government-backed Ally to increase its payout to the bankrupt mortgage lender.

Ally did not return calls for comment.

Gonzalez’s court-ordered report, which cost ResCap $80 million, has been kept under wraps since last month. Bankruptcy Judge Martin Glenn decided against making it public while ResCap hashed out the settlement, which was key to moving the case along.

ResCap and creditors who agreed to the settlement were concerned that the potentially explosive report might upend a deal.

After a year in bankruptcy, the company has been unable to come up with a restructuring plan to appease all its creditor groups.

The main holdout has been a Warren Buffett-led group of secured bondholders owed $800 million. Buffett’s Berkshire Hathaway owns about 40 percent of the bonds.

Berkshire had been pushing to release the report ahead of a reorganization plan. The Oracle of Omaha also was the one who initially succeeded in getting the court to appoint a special examiner to probe the relationship between Ally and ResCap.

Some creditors alleged that Ally hastened ResCap’s collapse by starving it of capital and stripping assets.

The report found that Ally left ResCap with an “unreasonably” small amount of capital before putting it into bankruptcy last year. It “reasonably should have believed it would incur debts beyond its ability to pay,” Gonzalez wrote.

Ally, formerly known as GMAC, still owes taxpayers more than $11 billion of its $17.2 billion crisis-era bailout, the second-largest outstanding TARP loan balance.

The firm cannot sell itself or go public, which would increase the chances of taxpayers getting repaid, without ridding itself of ResCap liabilities.

While also approving the outlines of a restructuring plan between ResCap and two main creditor groups, Judge Martin Glenn made clear he was not releasing Ally from claims by the Buffett-led creditor group and others.