The gas deal was inked in Shanghai during the current visit of Russian President Vladimir Putin to attend the Conference on Interaction and Confidence Building Measures in Asia in Shanghai.
"This is another major milestone achievement in China-Russia energy strategic cooperation," Chinese state energy giant CNPC said. It said the deal was "facilitated and greatly supported personally by the leaders of China and Russia".
Russia has vast energy reserves and China is constantly seeking resources to power the growth of its economy. Talks, which started in 2004 were stalled over price.
The two countries already have a 1,000 km-long oil pipeline which supplies over 15 million tonnes of Russian oil to China in 2012.
Two documents, China and Russia Purchase and Sales Contract on East Route Gas Project and a memorandum, were signed at a ceremony attended by Putin and Chinese President Xi Jinping.
Under the 30-year deal, the east route pipeline is scheduled to start providing China with 38 billion cubic meters of natural gas annually from 2018.