Moscow and Kiev have signed a preliminary deal on the transit of Russian gas to Europe via Ukraine, after months of difficult talks but ahead of the looming New Year deadline.

The current gas transit contract between the two ex-Soviet countries expires at the end of the year and ties between them have been shredded since Moscow annexed Crimea in 2014 and supported a separatist insurgency in eastern Ukraine.

"The Russian and Ukrainian sides have signed a memorandum of understanding," a spokesman for Russian gas giant Gazprom was cited as saying by Russian agencies, while giving no details of the deal.

Russia's Energy Minister Alexander Novak said it was a five-year deal which would be signed off before the end of the month.

The Ukraine presidency confirmed the deal on Facebook, adding that details would be made public on Saturday.

Last year Gazprom supplied Europe with 200.8 billion cubic metres of natural gas, with about 40 percent going through Ukraine, earning the country around $3 billion (2.7 billion euros) a year in transit fees.

The Nord Stream 2 gas pipeline is one of several Russia is developing to Europe
The Nord Stream 2 gas pipeline is one of several Russia is developing to Europe AFP / Tobias SCHWARZ

Russian President Vladimir Putin said Thursday that Moscow wants to keep some gas flowing through Ukraine, despite having built several pipelines to Europe since the current deal was agreed a decade ago.

Russia's gas pipelines include the Nord Stream 2 project which seeks to double gas volumes to Germany.

After three-way talks in Berlin Thursday -- involving Russia, Ukraine and the European Union -- Moscow and Kiev reached and "agreement in principle" and the talks continued Friday in Belarus.

Transit problems for Russian gas began after the fall of the Soviet Union when an independent Ukraine won control of the pipeline infrastructure.

Several supply crises followed, with Russia using gas as a weapon against Ukraine and cutting supplies repeatedly in 1992, 1993 and 1994.

The current contract between Russia and Ukraine was signed following the last gas crisis which ended up disrupting European supplies in 2010.