To the casual observer, it’s easy to doubt that China and Russia would have ever struck a natural gas supply and purchase deal during Russian President Vladimir Putin’s meeting with Chinese President Xi Jinping in Shanghai last month. After all, countless summits between Chinese and Russian leaders have come and gone with no final agreement signed for the long-discussed plans to ship more Russian gas to China. However, Putin and Xi finally ended an energy courtship, agreeing to a $400 billion deal for the delivery of 38 billion cubic meters of natural gas to China starting in 2018.

Long before the Chinese and Russian leaders on May 21 toasted their supply contract, the two countries had viewed each other as attractive natural gas partners. Russia regarded tapping into the Chinese market as essential to its plans to diversify its exports away from Europe, where natural gas demand is projected to grow at a substantially slower pace than in China. Meanwhile, the surge in China’s natural gas demand in recent years made the Chinese eye their northern neighbor, the world’s largest natural gas exporter, as an important source of supply to fill the gap between China’s domestic natural gas production and consumption.

Developments in the months leading up to the Shanghai summit may have provided Russia and China with added incentives to get serious about a natural gas marriage. For Russia, the new imperative is the country’s increased isolation from the United States and Europe in the wake of Russia’s annexation of Crimea and the resulting Western sanctions.

Europe’s renewed interest in finding alternatives to natural gas supplies from Russia, and the calls by U.S. policymakers and pundits for Washington to expedite the process for granting LNG export licenses and lift the virtual ban on crude oil exports to help wean Europe off Russian energy, undoubtedly made signing a gas pact with China even more appealing to Moscow.

For China, the country’s poor air quality and it’s “war on pollution” declared by Premier Li Keqiang in March likely increased the desirability of Russian natural gas. Indeed, the Chinese government’s announcement in April that the country aims to more than double the country’s natural gas consumption from 170 bcm in 2013 to 400-420 bcm in 2020 means China now needs Russian gas more than ever.

The major obstacle that Russia and China encountered on past attempts to make it to the altar was price. Russia did not want to sell gas to China at a price lower than it commanded in Europe, its largest customer. Meanwhile, China did not want to buy gas at a higher price than it paid Turkmenistan, its largest supplier of natural gas.

Although the Russians and the Chinese have come to a meeting of the minds on price, they are treating it as a commercial secret. Consequently, there has been much speculation by outside analysts about the price implied by the $400 billion contract and what it says about which country got the better deal. A back-of-the-envelope calculation yields an implied price of $350 per thousand cubic meters, which is close to what the Chinese are understood to have paid for gas from Turkmenistan last year. This estimate fits with the consensus among many outside observers in the lead up to the summit that Chinese had the upper hand due to Russia’s strained relations with the U.S. and Europe and the number of natural gas producers eager to supply the Chinese market.

That said, we do not know the pricing formula, the base number to be plugged into that formula or how a variety of other issues on the negotiating table – such as the apparent lack of upstream access in Russia for the Chinese, a rumored prepayment from the Chinese to the Russians, a Russian proposal to exempt gas sent to China from a mineral extraction tax, a Chinese proposal to exempt Russian supplies from an LNG import tax, and expectations  about the pace of natural gas price reform in China – influenced both countries decisions about price.

It is also important to note that this is not a marriage among equals. The natural gas supply agreement is the third time in the past decade that the Russians have brokered a multi-billion dollar energy deal with the Chinese in a time of need. In 2005, the China Development Bank and the Export-Import Bank of China were lenders of last resort to Rosneft, providing the Russian national oil company with a $6 billion oil-backed loan to help fund the purchase of the main production asset of a private Russian oil company, Yukos.

Four years later, the China Development Bank extended oil-backed loans worth $25 billion to Rosneft and Transneft, the state-owned pipeline operator, when oil prices collapsed and credit crunch during the global financial crisis left both Russian companies in a world of hurt. These deals have not only deepened bilateral energy relations, but also underscored a shift in power in the relationship away from Russia and toward China.

Regardless of which country may have conceded more, both countries can present themselves as winners to domestic and international audiences. The gas deal signifies that the China-Russia energy relationship is starting to live up to its full potential. Russia, which was China’s fourth largest crude oil supplier in 2013, is poised to become a major source of natural gas imports for its southern neighbor. This arrangement should provide Russia with greater security of demand and China with greater security of supply in the long-term. In the short-term, the main benefits of the gas agreement are political. Russia can claim a powerful friend in China, and China can point to another indicator of its growing economic and political clout on the world stage.

Erica Downs is a fellow in the John L. Thornton China Center at Brookings Institution. She focuses on the international expansion of Chinese companies and China’s energy and foreign policies as well as government-business relations in China, and was previously was an energy analyst at the CIA.