DETROIT - The U.S. government's foray into the car business is slowly coming to an end.

The Treasury Department said Wednesday that it would sell its remaining stake in General Motors Co. in the next year or so. That will wind down a $50 billion bailout that saved the iconic American car giant but also set off a heated debate about government intervention in private business that influenced this year's presidential election.

Taxpayers will lose money on the deal, but GM has done well over the last three years, piling up $16 billion in profits as sales bounced back. Now it looks forward to losing the stigma of government ownership - including the derisive moniker "Government Motors" - that it claims have cost it sales since it left bankruptcy protection in 2009.

As part of a deal announced Wednesday, GM will spend $5.5 billion to buy back 200 million shares from the Treasury through the end of the year. That will leave the government with 300 million shares, or a 19 percent stake, which it plans to sell during the next 12 to 15 months.

The government bailed out GM with $49.5 billion during the financial crisis in 2008 and 2009. Otherwise the struggling automaker would likely have been auctioned off in pieces. The Treasury Department says it will have recouped about $28.7 billion after GM completes its buyback. So, breaking even would require selling the remaining 300 million shares for an average of about $70 each.

That's more than double the current trading price. GM will buy the 200 million shares at $27.50 each, about an 8 percent premium over Tuesday's closing price of $25.49. The shares closed up 6.6 percent Wednesday, at $27.18.

At a more realistic price of $30 apiece, the government gets back $9 billion for its remaining shares. That means taxpayers would recoup around $38 billion, or about 77 percent, of the initial investment, resulting in a loss of about $12 billion.

GM says having the government as an owner kept customers away from dealerships. It will fund the deal out of its cash balance, which at the end of September was close to $32 billion.