Royal Bank of Canada (TSE: RY) is buying the Canadian business of Detroit-based auto financier Ally Financial Inc. for $4.1 billion as Ally raises money to pay back the U.S. government for bailing it out.

Ally Financial, known prior to a 2010 name change as GMAC, has been trying to dig itself out of $17.2 billion in debt from a government bailout that left it virtually a state-owned enterprise with the U.S. taxpayer owning as much as 74 percent of the company. The sale of its Canadian assets to RBC is leaving Ally Financial with $620 million above liquidation value.

For RBC, Canada's largest bank, the deal advances CEO Gordon Nixon's plan to find U.S. assets to bolster earnings in light of a slowdown in Canadian consumer lending.

The deal is RBC's biggest takeover after a $2.16 billion acquisition of Centura Banks in 2001, according to Bloomberg News.

As part of the deal, RBC agreed to provide low-rate auto loans for vehicle purchased from the Canadian unit of General Motors Company (NYSE: GM).

Toronto-Dominion Bank (NYSE: TD), a major competitor of RBC, announced almost at the same time that it was acquiring the consumer credit card portfolio from Target Corporation (NYSE: TGT) for equal to the gross value of the outstanding receivables for around $5.9 billion, depending on when the deal closes.

RBC shares fell 2.66 percent to C$57.04 ($57.42).