China and Russia signed a long-awaited natural gas supply deal on Wednesday, securing the world's top energy user a major new source of the clean-burning fuel and opening a market to Moscow as Europeans look elsewhere for their energy.

The deal would see Russia supply 38 billion cubic meters (bcm) of gas to China each year for 30 years under a contract valued in excess of $400 billion overall.

The gas will be transported along a new pipeline linking Siberian gas fields to China's main consumption centres near its coastline.

Russian President Vladimir Putin and Chinese counterpart Xi Jinping witnessed the deal in Shanghai between Russian state-controlled company Gazprom and China National Petroleum Corp (CNPC).

Gazprom declined to disclose what price was agreed, a key hurdle in talks that have dragged on for more than a decade.

Symbolically, for Putin the agreement represents a major triumph as he seeks to forge new partnerships in Asia while customers in Europe attempt to reduce their reliance on Russian gas in the wake of the crisis in Ukraine.

But from a commercial point of view, much will depend on the price and other terms of the deal.

One potential sticking point was whether China would pay a lump sum up front in order to fund some of the infrastructure costs, but as yet that element of the agreement remains unresolved, Gazprom's CEO Alexei Miller said.

Shares in Gazprom rose almost two percent in reaction to the announcement of the deal.