US car group Chrysler has secured court approval to sell most of its assets to a consortium led by Italy's Fiat.
The move, which is backed by both the US and Canadian governments, should enable Chrysler to exit bankruptcy protection in the near future.
Under the terms of the deal, Fiat will control 20% of Chrysler, while 68% will be owned by a union trust, and the two governments will share 12%.
It comes as General Motors is about to file for its own bankruptcy protection.
Under the terms of the Fiat-led deal, creditors holding $6.9bn (£4.3bn) of Chrysler debt will receive only $2bn. However, 90% of them backed the deal.
US bankruptcy protection is called Chapter 11
It gives US businesses time to rearrange their finances while continuing to trade, protected from their creditors
After filing, it is up to the judge to decide who gets paid and how much, balancing the interests of all parties
The judge holds hearings where all the parties give their views
His ruling can be appealed
Meanwhile, the two governments have agreed to provide about $8bn in loans to the new Chrysler.
Fiat is not paying anything for its 20% stake, which will give it access to the US car market. It has the option to increase its shareholding in Chrysler in the future.
In return, Chrysler will be able to take advantage of Fiat's expertise in making smaller, more fuel-efficient cars in its existing US factories.
Bankruptcy judge Arthur Gonzalez said in his written ruling that the only alternative to the sale would have been the "immediate liquidation" of Chrysler.
He added that the deal best protected the "public interest", and that the involvement of the two governments was necessary because "the marketplace alone could not offer" an alternative.
Judge Gonzalez turned down hundreds of objections to the deal, including one from a group of Chrysler dealerships who fear they will now be shut down.
Chrysler, which is the smallest of the three US carmakers after General Motors (GM) and Ford, filed for bankruptcy protection on 30 April. It could now emerge from bankruptcy protection as early as later this week.
Later on Monday GM is expected to enter bankruptcy protection, which will be the biggest corporate failure in US history.