Russian and Ukrainian companies signed a final five-year agreement safeguarding Russian gas transit to Europe via Ukraine, Kremlin-controlled gas giant Gazprom and Ukrainian President Volodymyr Zelenskiy said Dec. 30.

The deal, which came just 24 hours before the current agreement expires on Dec. 31, averted a potential Russian gas-flow interruption to Europe and helped Moscow avoid another blow to its reputation as a long-term energy supplier after Russian oil exports to Europe were contaminated earlier this year.

It was signed after five days of painstaking talks and followed a meeting between Russian President Vladimir Putin and Zelenskiy earlier this month in Paris.

"After five days of uninterrupted bilateral talks in Vienna, the final decisions have been made and final agreements have been reached," Gazprom CEO Alexei Miller said in a statement.

"The [signed] documents are effective as of today and provide for Russian gas transit via Ukraine after Dec. 31 2019."

Zelenskiy, fresh from a large-scale prisoner swap with rebel-held regions of Ukraine on Sunday, welcomed the deal, saying it could be prolonged by 10 more years.

"Europe knows, we won't fail it in terms of energy security," he said on his Facebook account. He said Ukraine would get at least $7 billion during the five years of the deal.

The European Union was worried that Russian supplies through Ukraine could be suspended if the current deal expired without a new agreement in place.

Wider Issue

The gas issue is a part of a wider political fallout between Moscow and Kiev.

The relations between the two fellow ex-Soviet republics plunged after Russia annexed Crimea from Ukraine in 2014 and the pro-Moscow uprising in eastern Ukraine.

On Dec. 29, Ukrainian government forces and pro-Russian separatists in eastern Ukraine completed a big prisoner swap after busing remaining detainees in the five-year conflict to an exchange point in the breakaway Donbass region.

The final deal on the Russian gas transit to Europe via Ukraine was finally sealed after the two countries initially agreed on the protocol on Dec. 20

Payment of $2.9 billion in legal damages by Russia to Ukraine on Dec. 27 was one of the key issues standing in the way of the gas deal. In response, Ukraine dropped more multibillion-dollar legal claims against Russia.

Russian gas exports to Europe outside of the former Soviet Union amount to about 200 billion cubic meters (bcm), while Kremlin-controlled Gazprom accounts for about 36% of the European gas market.

In 2018, Russian gas transit via Ukraine to Europe was 86.8 bcm. Under the terms of the new agreement, Russia has pledged to ship 65 bcm of gas via Ukraine in 2020 and 40 bcm annually from 2021 to 2024.