China and Russia have ratified a massive gas deal which will entail the construction of one of the world's biggest pipelines, as well as potentially lead to a paradigm shift in global energy markets.

During an official visit to Shanghai Russian President Vladimir Putin ratified a deal with Chinese President Xi Jinping for the supply of $400 billion’s worth of natural gas to China over a three decade period.

Under the deal Russia’s OAO Gazprom (OGZD), the world’s biggest producer of natural gas, will provide China National Petroleum Corp (CNPC) with supply equivalent to nearly a quarter of the country’s current consumption, and around 10 per cent of projected demand by 2020.

Supply is scheduled to commence by the end of the decade, with deal requiring Russia to invest $55 billion and China over $20 billion to ensure the realisation of the contract. Gazprom plans to build a $22 billion pipeline to China capable of conveying 38 billion cubic metres of product per year, which Putin has described as the world’s biggest construction project for the next four years.

The deal between OGZD and CNPC marks the culmination of negotiations lasting over a decade, which have until now been hampered by price disagreements. While Russia backed a benchmark price based on EU sales contracts, China advocated a lower price closer to the levels for its Central Asian imports.

Escalating tensions between Russia and the West over the former’s interference in Ukraine have played right into China’s hands, however. Russia has recently found itself with increased motivation to seal at the deal, as the US and European Union impose trade and financial sanctions in response to the annexation of Crimea.

In addition to being Russia’s biggest trading partner, with business between the two countries estimated at $94.5 billion last year, China was the only seat holder on the United Nations Security Council which refrained from rebuking Putin for interfering with its southern neighbour.

Just prior to concluding the deal Prime Minister Dmitry Medvedev told Bloomberg Television that “it’s time we reached an agreement with the Chinese on this issue.”

Negotiations persisted until the final hours of Putin’s two days visit to China, however, as both sides quibbled over prices, before finally agree upon the use of a formula related to that used for oil and oil products.

According to energy analysts the price eventually settled upon is closer to that originally desired by Russia, reflecting China’s desire to pay a premium for cleaner sources of fuel.