WILMINGTON, DEL. – Residential Capital, the defunct mortgage company once based in the Twin Cities, will end its bankruptcy within the next two weeks after winning court approval of a liquidation plan that resolves more than $100 billion in potential lawsuits, a company attorney said.

"This was probably the most overwhelming, most difficult bankruptcy of all time," the company's lead bankruptcy attorney, Gary Lee, with Morrison & Foerster, said in a phone interview Wednesday.

U.S. Bankruptcy Judge Martin Glenn in New York approved the plan at a hearing Wednesday and agreed to sign an order allowing the company to implement it, Lee said.

Under the plan, ResCap will distribute billions of dollars to creditors raised by liquidating assets, including a mortgage platform bought by Ocwen Loan Servicing and Green Tree Servicing for $3 billion. The company also sold a portfolio of loans for $1.5 billion.

Ending ResCap's bankruptcy allows its owner, Detroit-based Ally Financial Inc., to end "substantially all past, present and future mortgage-related claims," Ally said in a statement Wednesday.

ResCap filed for bankruptcy in May 2012 with plans to end potential lawsuits by settling with investors who bought mortgage-backed bonds. Investors had claimed the bonds were loaded with faulty mortgage loans and wanted ResCap and its parent to cover losses.

Ally was bailed out by the U.S. government, which became the majority owner of the auto-loan company.

ResCap settled with creditors who had wanted to sue Ally to force the company to contribute more to ResCap's bankruptcy.

Once the order is signed, the company's remaining employees will be transferred to a liquidating trust that will sell ResCap's remaining portfolio of mortgages, Lee said.