EU ambassadors have agreed to toughen regulations on a controversial gas pipeline from Russia to Germany, but they have decided not to back plans that might threaten its completion.
Work on the 1,225km (760-mile) Nord Stream 2 pipeline under the Baltic Sea is set to end this year, but it has angered several EU countries.
The EU wants to bring pipelines coming into the bloc under its energy rules.
But Germany feared that would make the new pipeline uneconomic and unviable.
In the end 27 of the bloc's 28 ambassadors reportedly agreed to a Franco-German compromise.
France said it was delighted that Germany had agreed to place Nord Stream "under European control", and in return Germany is likely to remain as lead negotiator on the project.
German Chancellor Angela Merkel also praised the deal.
What are the worries with Nord Stream 2?
Russia currently supplies around 40% of the EU's gas supplies, just ahead of Norway, which is not in the EU but takes part in the bloc's single market. The new pipeline would increase the amount going under the Baltic to 55bn cubic metres a year.
For years, the 28-member bloc has been concerned about reliance on Russian gas.
Poland has warned that Russia could use Nord Stream 2 to harm Europe's energy security, and US President Donald Trump even accused Germany of being a "captive" of Russia because of it.
Nord Stream 2 will not only increase Russia's supply, it also means that, along with its TurkStream project, Russia will be able to bypass Ukrainian pipelines. The loss of transit fees would hit Ukraine's economy hard.
The EU is also trying to look beyond Russian gas - to imports of US liquified natural gas (LNG) and new pipelines, such as a planned Norway-Poland pipeline via Denmark, that would supply Sweden and other neighbouring states.
Why is Germany backing the new pipeline?
German businesses have invested heavily in Nord Stream 2 and former Chancellor, Gerhard Schröder is running the project.
As well as Germany's Uniper and BASF's Wintershall unit, other European companies have stakes too, including Anglo-Dutch Shell, OMV of Austria and Engie of France.
Chancellor Angela Merkel tried to assure Central and Eastern European states on Thursday that the pipeline would not make Germany reliant on Russia for energy.
"Germany will expand its network of gas terminals in regards to liquified gas. Meaning, for gas we do not want to be at all dependent on Russia alone," she said.
Russian government spokesman Dmitry Peskov said Moscow hoped the disagreement would be sorted out. "We still believe that this project is beneficial to both the European gas consumers' interests and to Russian Federation as gas supplier," he said.
What is in the EU deal?
Ultimately it came down to a compromise struck between France and Germany, a day after the French government had announced it was withdrawing its support for Germany.
A key part of the deal, according to French diplomats, is that Nord Stream 2 is not threatened as a project but now faces stricter controls and maybe revision too.
A big priority for the EU is to increase competition.
So, instead of having a patchwork of different agreements for pipelines entering the bloc, they would have to come under the EU's rules for the internal energy market.
Those rules include separation of ownership of the pipes from the supplier - known as unbundling. With Nord Stream 2, Russia's Gazprom controls both.
However, under the deal, the rules apply from the "territory and territorial sea of the member state where the first interconnection point is located".
In the case of Nordstream 2 it seems unlikely those rules would cover the pipeline under the Baltic Sea before it reaches the interconnector network. Any changes required to the project would also be renegotiated by Germany.
The text may still change as it will now go to the European Parliament, where many MEPs have concerns about dependence on Russian gas.