General Motors Corp signed a deal on Friday to sell its best assets to a new company that will be majority-owned by the U.S. government, essentially taking the vast majority of the company out of bankruptcy, a source familiar with the matter said.

The government and GM signed the documents at 6:30 a.m. Friday, ending a whirlwind 40-day bankruptcy for GM that concludes with selling its key operations and core brands such as Chevrolet, Cadillac, Buick and GMC to the new company.

(Reporting by Jui Chakravorty Das; Editing by Lisa Von Ahn)