Image copyright Reuters Image caption Gazprom CEO Alexei Miller (centre) and CNPC Chairman Zhou Jiping shake hands as Russian President Putin looks on during the signing ceremony in Shanghai

Russia's President Vladimir Putin has signed a multi-billion dollar, 30-year gas deal with China.

The deal between Russia's Gazprom and China National Petroleum Corp (CNPC) has been 10 years in the making.

Russia has been keen to find an alternative energy market for its gas as it faces the possibility of European sanctions over the crisis in Ukraine.

No official price has been given but it is estimated to be worth over $400bn.

President Putin said in a statement to the Russian news channel Rossiya: "The price is satisfactory for both sides.

"It is tied, like it is envisaged in all our international contracts with Western partners, specifically our partners in Western Europe, to the market price on oil and oil products. It is an absolutely calibrated, general formula for pricing."

Gazprom shares rose 2% on the news.

Media playback is unsupported on your device Media caption How significant is the deal?

The agreement, signed at a summit in Shanghai, is expected to deliver some 38 billion cubic metres of natural gas a year eastward to China's burgeoning economy, starting around 2018.

The main argument has been over price and China is thought to have been driving a hard bargain.

Over the last 10 years it has found other gas suppliers. Turkmenistan is now China's largest foreign gas supplier, and last year it started importing piped natural gas from Myanmar.

Alexei Miller, Chief Executive of Gazprom said the new deal was "the biggest contract in the entire history of the USSR and Gazprom - over 1 trillion cubic metres of gas will be supplied during a whole contractual period."

Analysis: Jamie Robertson, BBC News

The gas deal between Russia and China was signed at 04:00 China time, which gives some indication of the level of urgency over these talks. Mr Putin appears to have been determined not to leave Shanghai without a deal - and he got one.

But the financial details are a "commercial secret", so we don't know how much he had to give away to get it. Certainly China needs the gas to help it cut its coal-fired smog levels, and it wants to diversify supply. But it had the luxury of time in which to negotiate, something Mr Putin was short of.

The perceived motive for the deal is that Russia needs a second market for its gas, so it can face up to European sanctions. Given that the "Power of Siberia" pipeline won't start pumping gas into Chinese factories until 2018 at the earliest, its economic effect on the European crisis will be limited.

More important may be the investment that China will make into Russia's power and transport infrastructure. Putin may not have managed to sign the most advantageous of gas deals on Wednesday but the opening of economic doors with China could well be the greater achievement.

Rain Newton-Smith, head of emerging markets at Oxford Economics, said: "The whole tenet of the deal has a symbolic value - it says that the two countries are prepared to work with one another. For instance there were other elements such as Chinese participation in Russian transport infrastructure and power generation.

"It is similar in many ways to China's investments in Africa where they drive a hard bargain over the price of raw materials but then provide infrastructure for the economies they are doing business with.

Jonathan Marcus, the BBC's defence and diplomatic correspondent said tensions between Russia and the west were not just over Ukraine: "There are fundamental differences over Syria and about the whole direction in which President Vladimir Putin is taking his country.

"Thus this deal could symbolise an important moment of transition - when both in economic and geo-political terms, Russia's gaze begins to look more towards the East than towards the West."

Siberian power

Another sticking point on the deal has been the construction of pipelines into China.

Currently there is one complete pipeline that runs across Russia's Far East to the Chinese border, called The Power of Siberia. It was started in 2007, three years after Gazprom and CNPC signed their initial agreement in 2004.

But financing the $22-30bn cost of sending it into China has been central to the latest discussions.

China is Russia's largest single trading partner, with bilateral trade flows of $90bn (£53bn) in 2013.

The two neighbours aim to double the volume to $200bn in 10 years.