General Motors (GM) has announced that it has chosen the Canadian car parts manufacturer Magna to buy Opel and its sister company Vauxhall.
The decision was welcomed by German Chancellor Angela Merkel, who said she was "very pleased" about it.
Magna, which is backed by Russia's Sberbank, has said that it will keep all four German plants open.
But British unions have expressed concern about the future of Vauxhall's 5,500 UK workers.
A spokesman for Magna said that the company is committed to keeping open the Ellesmere Port plant, where the Astra is made.
But UK Business Secretary Lord Mandelson said he had received assurances from Magna "that the futures of both plants are secure."
He did, however, say that all of Opel's and Vauxhall's workforce across Europe "will face restructuring."
By Jorn Madslien, Business reporter, BBC News
Victory for German Chancellor Angela Merkel in the lengthy tug-of-war over the future of Opel should go a long way towards safeguarding the jobs of most, if not all, of the company's 25,000 workers in Germany.
But although the sale of a controlling stake to Magna is backed to the tune of 4.5bn euros (£4.5bn; $6.5bn) by the German government, it does not remove the need for sharp cost-cuts elsewhere.
The sale signals the start of a restructuring process, with an expected 10,000 out of 50,000 Opel and Vauxhall jobs in Europe being axed.
Chancellor Merkel has said she will discuss with its European partners "the distribution of the burden", which probably means that any European government wanting to safeguard jobs in their country must also come up with substantial amounts of cash.
Magna said that the company plans to honour its existing contract to produce vans in Luton until 2013, and will try to find a way to keep the plant in production after that date.
"The uncertainty surrounding the ownership of Vauxhall is now over, but the uncertainty surrounding the long-term future of Britain's plants will continue," said Tony Woodley, general secretary of the Unite union.
"We need to make sure that British plants and people are not treated disproportionately during the restructuring that will take place."
Other Opel plants outside Germany are also at risk.
Magna proposals outline the option of winding down production at a plant in Antwerp in Belgium, and of shifting some production from Zaragosa in Spain back to Germany.
GM will be selling a 55% stake in the new Opel to Magna and Sberbank. Employees will hold a 10% stake and GM will keep the rest.
The Opel Trust, which controlled that 65% of GM's European operations, approved the deal.
It said it strongly believed it was "in the best interests of Opel and Vauxhall and their employees".
The German government has already lent 1.5bn euros to Opel, and will now put up an additional 3bn euros in loan guarantees for Magna.
Trust chairman Fred Irwin said they had recommended - "given the burden on German taxpayers and for the sake of German jobs" - that those guarantees be used for Opel in Germany only.
A statement from GM said it needed to finalise a financing package from the German government.
Other issues outstanding included written agreement from unions to support its cost-cutting programme, GM said.
Chancellor Angela Merkel said that "patience" during the long-running discussions had led to a decision being reached.
BBC Berlin correspondent Steve Rosenberg said this was a victory for the German chancellor who had staked her reputation on closing the deal.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.