Reuters Newsagency says Judge Robert Gerber of the US bankruptcy court in Manhattan said the sale would "prevent the death of the patient on the operating table."
GM, which filed for bankruptcy protection on June 1, had argued that it would be forced to liquidate if the sale was not approved.
The US government said it could walk away from funding the carmaker if a deal was not approved by July 10.
"If GM liquidates, there will not only be nothing for stockholders; there will be nothing for unsecured creditors," Judge Gerber said in a 95-page opinion.
Under the deal, New GM will operate the best parts of the old company, including its Chevrolet and Cadillac brands, with a less-expensive workforce, smaller dealer network, and much less debt.
Almost immediately GM announced that most of its assets would be transferred to NGMCO Incorporated, an entity funded by the US Treasury Department.
It said that ultimately NGMCO Inc would change its name to General Motors Company and continue to operate under GM's historic corporate and sub brands.
The "old GM," which includes unpopular brands and unneeded factories and liabilities, will remain behind in bankruptcy court to be liquidated.
The US Treasury has agreed to provide US$60 billion in financing to the new company, including a proposed US$50 billion that would give it a 60 per cent stake in the company.
The United Auto Workers will gain a 17.5 per cent stake, the Canadian government about 12 per cent, and GM bondholders would be expected to obtain about 10 per cent of the new company.
At a three-day sale hearing that concluded July 2, some small bondholders had objected to the deal, but no other bidders presented an alternative, and the 100-year-old company warned of "catastrophic" consequences to the auto industry if the sale was blocked.
A successful sale of GM's main assets is the second big victory for the automotive industry task force of President Obama’s administration after it helped broker the sale of Chrysler LLC to a group led by Italy's Fiat SpA last month.
A task force official said earlier this month that the government could conduct an initial public offering for the "New GM" as soon as 2010.