The bankruptcy, which still needs court approval, came early Monday as ResCap faced looming bond payments and a possible loss of financing from its parent, which is eager to shed mortgage liabilities that have left it limping in the wake of the financial crisis.

At the same time, Nationstar Mortgage Holdings Inc, which is majority-owned by Fortress Investment Group LLC, struck a deal to buy substantially all the mortgage-servicing and related assets from ResCap for about $2.4 billion, including debt.

The deal will make Nationstar the opening bidder in a court-supervised auction.

Ally has been besieged in the past few years by losses at ResCap, once a major subprime lender and profit engine. The company has considered bankruptcy for ResCap and other ways to shed the unit since at least 2009, but has never pulled the trigger.

The bankruptcy declaration is intended to help Ally focus on its main auto lending and Internet banking businesses and put together a plan to pay back U.S. taxpayers.

"The single most important thing we can do for the U.S. taxpayer is to not put billions of dollars into this business on a going-forward basis," Ally CEO Michael Carpenter said in an interview.

ResCap plans to sell its remaining mortgage loans and other assets for $1.6 billion to Ally, unless another bidder steps up. ResCap, which will continue operating in bankruptcy, then plans to wind down.

Nationstar would emerge as a top U.S. mortgage servicer if its bid is successful. The purchase would give it more than $370 billion in new loans to service, while any liabilities would stay with the ResCap bankruptcy estate.

BAILOUTS

The U.S. Treasury Department injected $17 billion into Ally through multiple bailouts during the financial crisis and now owns nearly 74 percent of the company. Ally still owes the government about $12 billion, counting dividend payments by the lender and sale of some securities by the Treasury.

The bankruptcy comes as pressure increases on Ally to repay that money and problems at ResCap become increasingly unmanageable. The Obama administration is trying to recoup money from crisis-era bailouts before the presidential election in November and does not want Ally to become a black mark on the auto industry restructuring.

Timothy Massad, assistant U.S. Treasury secretary for financial stability, called the bankruptcy filing unfortunate but necessary.

"We believe that this action puts taxpayers in a stronger position to continue recovering their investment in Ally Financial," he said.

ResCap is a rare example of a subsidiary of a bank holding company filing for bankruptcy. It could serve as a road map for Bank of America Corp as it grapples with its struggling Countrywide mortgage business, one bankruptcy expert said.

"If it works, it's possible this is the beginning of the end of this part of the whole mortgage mess," said Stephen Lubben, a law professor at Seton Hall University School of Law.

BOARD APPROVES FILING

ResCap's board approved the filing in a meeting that started around 6 p.m. Sunday, but negotiations with creditors and investors extended into Monday morning, a person familiar with the situation said.

Ally will take a $1.3 billion charge, which covers its $400 million equity investment in ResCap, a $750 million settlement with ResCap and $130 million in reserves for claims related to mortgage-backed securities.

In return, Ally receives legal releases to claims over mortgage-backed securities with ResCap and third-party litigants. Ally said ResCap has also obtained support for its restructuring from certain noteholders.

In addition, some investors in residential mortgage-backed securities (RMBS) issued by ResCap will support the reorganization. ResCap and 17 institutional investors reached a proposed settlement in which ResCap will grant an $8.7 billion claim to 392 RMBS trusts issued from 2004 to 2008, the law firm for the investors said in a statement.

Ally will also seek "strategic alternatives" for its auto, insurance and banking businesses in Canada, Europe, Britain, Mexico and South America. These operations have about $30 billion in assets.

Carpenter said after these divestitures, ResCap will likely have paid back about two-thirds of the bailout money. He expects ResCap to emerge from bankruptcy by year's end, with the divestitures complete or far along.

RESCAP DEAL

Ally is the fifth-largest mortgage servicer in the United States and the country's 10th-largest originator of home loans, according to the latest data from Inside Mortgage Finance.

ResCap has 2.4 million customers and 3,600 employees.

Of Nationstar's total purchase, the equity portion is expected to be $880 million, consisting of about $700 million for the servicing rights and $180 million for the advances.

About half the equity is coming from Nationstar and the rest from Newcastle Investment Corp, a mortgage REIT managed by Fortress, and other Fortress funds. There is a $72 million breakup fee and reimbursement of up to $10 million of transaction-related expenses if Nationstar does not win the auction.

The transaction is expected to close by year end.

Wesley Edens, co-founder of Fortress, said he expected other bidders in the auction but that Nationstar is well-positioned.

Barclays Plc is arranging a $1.45 billion debtor-in-possession financing for operations during the bankruptcy.

Ally does not have publicly traded shares, but has stockholders. Besides the Treasury, a trust for GM holds 9.9 percent and private equity firm Cerberus Capital Management owns 8.7 percent.

(Reporting by Rick Rothacker in Charlotte, N.C., and Paritosh Bansal in New York; Additional reporting by Caroline Humer and Ben Klayman; Editing by Maureen Bavdek and Matthew Lewis)

By Rick Rothacker and Paritosh Bansal