Germany heaved a sigh of relief on Saturday over a deal with Canadian auto parts group Magna, General Motors and the U.S. government to save carmaker Opel from the imminent bankruptcy of its U.S. parent.

The accord sealed after six hours of talks in Chancellor Angela Merkel's offices still needs final approval but seemed set to ringfence Opel and its 50,000 workers in Europe from a GM Chapter 11 bankruptcy filing widely expected for Monday.

Merkel said U.S. President Barack Obama -- due to visit Germany next week -- helped swing the deal with a telephone call on Friday.

That helped clear hurdles over financing that had threatened to scupper the entire transaction and allowed GM to agree the deal with Magna about the future of its European operations, of which Opel is the centerpiece.

I spoke on the phone with the American president yesterday and we were in agreement that we had to do everything possible to come up with a good result for this complicated task, Merkel told reporters. That conversation clearly influenced the negotiations last night.

Labour leader Klaus Franz said some Opel workers arriving for early Saturday shifts hugged each other in spontaneous celebrations even though some worried the proud company, which traces its roots to the 19th century, was not out of the woods.

This was pure emotion, Franz told Reuters Television. I have to see now how to get the adrenaline levels down.

Opel workers favored Magna over rival suitor Fiat even though Magna will cut some 11,000 jobs in Europe, a quarter in Germany. Plants in Belgium and Britain may not survive.

It's really super, said one beaming Opel worker as he headed into Opel's main plant in Russelsheim at 6 a.m.

It's good that we're still alive, said one middle-aged Opel factory worker. But we still have to see what comes out of all this, where jobs will be cut. We'll probably end up having to pay the bill. But the main thing is: we're still alive.

There was no word on the fate of plants outside Germany, including two in Britain, where unions have accused the government of being much less energetic about saving jobs.

Like its parent GM, Opel has suffered acutely from world recession. Its fate has gripped Germany, where the auto industry remains a potent symbol of the country's postwar recovery.

Merkel faces an election in September and was keen to avert large job losses.

Finance Minister Peer Steinbrueck emerged from the marathon meeting at 2:15 a.m. to tell journalists a comprehensive deal was agreed that included bridge financing worth 1.5 billion euros ($2.1 billion) and a trustee model for the carmaker.

Siegfried Wolf, the co-chief executive of Magna, cautioned there were still details to be ironed out. In five weeks' time we should have the formal signing of the contract, he said.

Hesse state premier Roland Koch said, for example, the state assemblies in both Hesse and North Rhine-Westphalia -- two of four states with Opel plants -- would still have to endorse it. He said he hoped that could be completed by Sunday.

RUSSIAN INVOLVEMENT

Magna plans to use Opel to push into Russia, Europe's fastest-growing car market before the economic crisis hit.

Russian state-controlled Sberbank, which is helping to finance the deal and is set to get a 35 percent stake in Opel, welcomed the agreement as a way to restructure the Russian automotive industry.

To my mind, this is a very good chance for Russia to obtain one of the most advanced European automakers in terms of technology for an unprecedentedly low price, Chief Executive German Gref told the Vesti 24 news channel.

Yelena Matveyeva, deputy head of Magna's Russian partner GAZ, also hailed the accord, which will give the carmaker access to technology and boost output at its plant.

The German government has been scrambling to safeguard Opel's future before GM files for bankruptcy. A first round of talks collapsed amid mutual recriminations on Thursday.

Italian carmaker Fiat pulled out of talks on Friday, leaving the door open for Magna, a company started by Austrian emigre Frank Stronach in a Toronto garage nearly half a century ago.

Magna and Opel had presented their plan to senior German officials and representatives of the U.S. Treasury to win their support and ensure the release of the financing that Opel desperately needs to survive over the coming months.

An agreement between GM and Magna is a first step toward securing the future of Opel, which GM bought in 1929.

I think this is the start of a new future for Opel, for the workers, the company and the brand, GM Europe head Carl-Peter Forster told journalists. He added, however, that there would still be some hard negotiations on the fine-print ahead.

MINISTER'S MISGIVINGS

Economy Minister Karl-Theodor zu Guttenberg renewed his reservations about risks involved with the rescue but added there would also have been risks if Opel declared bankruptcy.

In a sign of conservatives' misgivings about state aid for companies, a source close to the situation said Guttenberg had handed the lead role in the Opel rescue to Merkel's office. But Merkel praised her party ally for raising critical questions.

Another stumbling block had been U.S. Treasury opposition to German demands that Opel assets be temporarily placed in a trust to protect them from GM creditors. Germany will now release the bridge financing to tide Opel over until a merger is completed.

Based in Ruesselsheim near Frankfurt, Opel employs 25,000 staff in four German plants. It is part of a GM Europe operation that makes cars in Spain, Poland, Belgium and Britain, where Opel cars are sold under the Vauxhall brand.

(Additional reporting by Christiaan Hetzner in Frankfurt, John McCrank in Montreal, Ian Simpson in Milan; Tom Kaeckenhoff in Duesseldorf; Anton Doroshev in Moscow; Writing by Erik Kirschbaum and Noah Barkin; Editing by Mike Peacock)