Moscow and Kyiv on Monday signed a five-year agreement on the transit of Russian gas to Europe via Ukraine, finalizing months of difficult talks just ahead of a New Year deadline.
The current deal between the two ex-Soviet countries expires Tuesday, and ties between them have been in tatters since Moscow annexed Crimea in 2014 and supported a separatist insurgency in eastern Ukraine.
About 18% of the European Union's annual natural gas consumption comes from Russia via Ukraine, putting additional pressure on EU officials who helped to broker the deal.
"Ukraine has signed a five-year transit contract," Ukrainian President Volodymyr Zelensky announced on his Facebook page, nearly two weeks after a provisional deal was reached.
A wide range of documents and contracts were involved and together formed "a package deal which has re-established the balance of interests," Alexei Miller, the boss of the Russian gas giant Gazprom, was cited as saying in a statement.
The documents were signed after five days of non-stop talks.
Gazprom is expected to ship at least 65 billion cubic meters (2.3 trillion cubic feet) of natural gas via Ukraine next year, and at least 40 billion per year from 2021 to 2024, said Zelensky, from which Kiev would earn "more than $7 billion."
Russia's Prime Minister Dmitry Medvedev called the deal a "compromise" and added in a message on Facebook that "all mutual grievances have been ended."
EU Commission vice president in charge of energy Maros Sefcovic called the deal "great news for Europe's energy security."
"All pieces for the transit of gas via the Ukrainian route are now in place," he wrote on Twitter.
Last year, Gazprom supplied Europe with 200.8 billion cubic meters of natural gas, about 40% of which passed through Ukraine for roughly $3 billion in transit fees.
Russian President Vladimir Putin said earlier this month that Moscow wanted to keep some gas flowing through Ukraine, despite having built several pipelines to Europe since the current deal was agreed upon a decade ago.
The new agreement comes days after Gazprom paid $2.9 billion to Ukraine's Naftogaz to settle a long-running dispute over transit fees that had blocked the deal.
Meanwhile, Russia is pursuing work on the Nord Stream 2 project that is to be completed by the end of next year and would double gas shipments to Germany.
The United States has long opposed the 9.5-billion-euro ($10.6-billion) project and the U.S. Senate voted last week to levy sanctions on companies working on it.
Washington believes the pipeline will give Russia too much influence over security and economic issues in western Europe.
Transit problems for Russian gas began after the fall of the Soviet Union when independent Ukraine took control of the pipeline infrastructure.
Several crises followed, with Russia using gas supplies to put pressure on Ukraine by cutting them repeatedly in 1992, 1993 and 1994.
The last gas crisis disrupted supplies to Europe in 2010.