Residential Capital, the besieged mortgage unit of Ally Financial, filed for bankruptcy.

"The action by ResCap will enable Ally to achieve a permanent solution to its legacy mortgage risks and put these issues behind us," said Ally CEO Michael Carpenter. "This action, along with pursuing alternatives for the international businesses, will allow Ally to focus 100% of its energies on further strengthening its already leading U.S. auto finance and direct banking franchises."

Ally expects to take a $1.3 billion charge in the second quarter for the filing.

The parent bank said ResCap will continue servicing and originating home loans during the process.

In a separate announcement Monday, Nationstar Mortgage Holdings (NSM) a servicer based in Texas, paid $700 million to acquire $374 billion in mortgage servicing rights from ResCap. Included in the deal are $201 billion in primary servicing rights and $173 billion in subservicing contracts.

Ally executives said the prearranged plan will settle all existing and potential claims between Ally and ResCap along with actions from third parties.

Ally will make a $750 million cash injection into ResCap as part of the plan.

Ally made a stalking-horse bid on the entire mortgage unit of $1.6 billion or 45% of the unpaid principal on loans owned by ResCap. This bid will serve as a benchmark for companies looking to buy ResCap or its assets.

A $150 million financial facility will be created for the bankruptcy as well.

Investors holding at least a 25% stake in 290 mortgage-backed securities issued by ResCap gave support to the action as part of a settlement. These bonds, out of the 392 total from ResCap, have an original principal balance of $164 billon.

The company will also set up a $130 million mortgage repurchase reserve to buy back defaulted loans from investors. It will replace the reserve originally held at Ally.

The Treasury Department held a 74% stake in Ally before the filing. The bank said it paid back an additional $5.5 billion Monday, to reduce the taxpayer interest in the company by one-third. After completing the bankruptcy, Ally said it would pay back another third.

Timothy Massad, assistant secretary for financial stability at the Treasury, supported the action Monday.

"We believe that by addressing the legacy mortgage liabilities at ResCap, the action taken today will put taxpayers in a stronger position to maximize the value of their remaining investment in Ally," Massad said in a statement.