GM is to be relaunched in July
A US judge has approved a bankruptcy plan for car giant GM, which allows the firm to transfer its profitable assets to a new government-backed firm.
Judge Robert Gerbert gave the plan the go-ahead late on Sunday, saying the sale would prevent "the death of the patient on the operating table".
GM filed for bankruptcy protection on 1 June, saying it would be forced to liquidate if the plan was not approved.
The new streamlined General Motors will be 60% owned by the US government.
The bankruptcy plan had been opposed by several groups - including some of GM's bondholders, unions and consumer groups - who had argued that their needs were being ignored in favour of the interests of the carmaker and the government.
But Judge Gerbert argued that the 850 objections were not valid.
In a 96-page opinion, he said: "If GM liquidates, there will not only be nothing for stockholders - there will be nothing for unsecured creditors."
This would be a "disastrous result", he added.
In effect, a new, smaller GM is being created with a reduced workforce, smaller dealer network and less debt.
It will operate the best parts of the old company, including its Chevrolet and Cadillac brands. Its European operation, Opel, is being sold off.
The firm is getting $60bn (£37.3bn) in financing from the US Treasury, which gives the US government a 60% share in the "new" GM, while the United Auto Workers union would have 17.5%.
Canada's government would have a 12% share and GM bondholders would own about 10% in the new company.
The new firm is set to be launched in mid-July.
"This has been an especially challenging period, and we've had to make very difficult decisions to address some of the issues that have plagued our business for decades," said GM president and chief executive, Fritz Henderson.
"Now it's our responsibility to fix this business and place the company on a clear path to success without delay."
GM's downfall began after it, along with other US carmakers, was slow to react when drivers started to switch to smaller, more fuel-efficient cars.
Heavy discounting aimed at maintaining the American public as customers led to sharp cuts in profits, which eventually turned into losses. The company was last profitable in 2004.
Last December, along with now-bankrupt rival Chrysler, GM was forced to go cap in hand to the US government for a bail-out to keep it going.
It got handouts of more than $19bn while its finance arm, GMAC, also had to be bailed out.