Russian President Vladimir Putin Wednesday oversaw a vast gas deal with China said to be worth $400 billion as the Ukraine crisis threatens Russian energy exports to Europe and his country faces Western sanctions. The gargantuan 30-year deal finally came to fruition after a decade of negotiations. It represents a turn to the east by Moscow at a moment when its geopolitical assertiveness, particularly the takeover of Crimea, has seen it heavily criticised by the West. The signing in Shanghai was witnessed by Putin and Chinese President Xi Jinping, said Chinese energy giant CNPC, the country's largest oil and gas producer and a party to the contract. "This is another major milestone achievement in China-Russia strategic energy cooperation," CNPC said in a statement. Russia has been seeking more Asian markets, and its gas supplies to Europe via Ukraine are currently under threat because of unpaid bills by Kiev. European Commission chief Jose Manuel Barroso told Putin in a letter Wednesday it was "imperative" that negotiations over payments by Ukraine continued, and that supplies were maintained during the talks. For its part, China is constantly seeking resources to power the growth of its economy, the world's second largest. But China and Russia had for more than a decade been unable to agree on a price for the gas. CNPC did not announce pricing information on the deal. Russian media reports cited Alexei Miller, the chief of Russia's energy giant Gazprom, as saying the gas deal was worth $400 billion over its full term. It was the firm's biggest-ever single agreement, he said, adding: "Such a contract has never been signed with any other company." - 'Putin gets a big win' - Moscow's relations with the United States and European Union have plunged to a post-Cold War low in recent months over Russia's annexation of Crimea and Western accusations it is fomenting unrest in eastern Ukraine. The West has slapped sanctions on some of Putin's closest allies and threatened broader punitive measures if Moscow disrupts presidential polls in Ukraine on May 25. At the same time Russia and China, both veto-wielding members of the United Nations Security Council, have sought to strengthen their ties and have often worked in lockstep to contain Washington in recent years. "This is a big deal that has been over a decade in the making," Raffaello Pantucci, senior research fellow at the Royal United Services Institute for Defence and Security Studies, told AFP. "The Russians in particular wanted to walk away from these meetings in China, highlighting that they have lots of other substantial options on the table in the face of tensions with the West over Ukraine," he said. "Putin gets a big win and can go back home showing that he has also managed to finally conclude a discussion that had been going on for over a decade," he added. Putin is visiting Shanghai to attend an Asian security forum and launch joint naval exercises with China, but officials from both countries had touted the energy deal as a possible highlight of the trip. - 'Strategic partners' - Under the 30-year contract between CNPC and Gazprom, 38 billion cubic metres of gas a year could eventually be exported from Russia to China, the CNPC statement said. The amount is just over half the 70 billion cubic metres envisaged under a 2009 framework agreement between the two. Two agreements are involved in the supply deal, one between CNPC and Gazprom and one between the governments. Analysts said the deal could help China increase the proportion of cleaner-burning gas in its energy mix. "This provides a foundation for both countries to become true strategic partners in the energy sector," Zhao Huasheng, director of the Center for Russia and Central Asia Studies at Fudan University, told AFP. "The breakthrough achieved in this project reflects the potential for both countries to expand their cooperation beyond this contract," he said. China claims it is the world's third largest consumer of natural gas, importing 53 billion cubic metres last year, according to state media. Shares in CNPC's listed unit, PetroChina, had risen in anticipation of an agreement. On Wednesday before the deal was announced, the stock closed up 0.52 percent in Shanghai and rose 0.22 percent in Hong Kong where it is also traded.