As Russian President Vladimir Putin arrives in Shanghai for a two-day conference that begins Tuesday, relations have rarely been as smooth between his country and China.

Across a range of measures, from economic to military to diplomatic, Moscow and Beijing have reached a tremendous synergy remarkable for two countries which, just 30 years ago, had better relations with the United States than they did with each other.

The significance of this geopolitical shift is not lost on Moscow. Speaking to the Chinese media, Putin said Russia’s positions “on the main international issues are similar or even identical” to China’s and that “it would not be wrong to say that it has reached the highest level in all its centuries-long history.”

Russian and Chinese actions match Putin’s words. The two countries are finalizing a deal to ship Russian gas to China, to the tune of 38 billion cubic meters annually by the end of this decade, a figure that may eventually reach 61 billion. This accord would follow on the heels of a $270 billion agreement last year for Rosneft, a state-owned energy giant, to double its oil exports to China. The economic logic of these deals is clear: Russia can diversify its export market from Europe, with which it has an increasingly tense relationship, and capitalize on Beijing’s resource thirst to the east.

The Chinese-Russian chumminess goes far beyond economics. On Tuesday, the two Asian powers will hold joint naval exercises in waters just northwest of the Senkaku/Diaoyu Islands, a tiny archipelago in the East China Sea that Japan also claims and currently occupies. Though military exercises between the two countries are hardly unprecedented, their announcement -- just one day after President Barack Obama concluded a visit to the region with an endorsement of Japanese administration of the islands -- is unlikely to be a coincidence.

Relations between China and Russia have not always been smooth, even during the 1950s when the two countries were Communist allies. In 1960 Beijing and Moscow cut ties, and the two even fought two minor wars along their lengthy shared border. The relationship only thawed in the late 1980s when then-Soviet leader Mikhail Gorbachev conducted a historic state visit in Beijing.

Since the collapse of the Soviet Union in 1991, which ushered in an unparalleled era of American hegemony, China and Russia have found common cause in thwarting Washington’s global ambitions. Although both countries expressed rhetorical support for the American war against terror, both opposed the 2003 U.S. invasion of Iraq. More recently, China and Russia have used their veto power on the U.N. Security Council to prevent Washington and its allies from providing lethal aid to the Syrian opposition. This arrangement has a clear historical parallel: Just as President Richard Nixon made a historic opening to China in 1972 to balance against their then-common enemy, the USSR, Russia and China have done the same to Washington.

But despite Beijing and Moscow’s present friendliness, contentious issues remain. Consider Ukraine. China has remained neutral in Putin’s decision to annex Crimea, a Ukrainian region populated mainly by ethnic Russians. But this action violates China’s traditional defense of national sovereignty, a position Beijing maintains to discourage foreign support for separatist movements within its own borders. (And -- lest this thought be lost on the Communist Party, its Central Propaganda Department explicitly ordered journalists to avoid this reference.)

Then, there’s ex-Soviet Central Asia. Even after achieving independence with the collapse of the Soviet Union, the five countries have maintained a close relationship with Russia. But China has made inroads. The Shanghai Cooperation Organization, established in 1996, has greatly increased relations between Beijing and the states on its western border.

China and Russia’s friendship could not have come at a worse time for the United States. Russia’s annexation of Crimea has severely strained its relationship with Washington, now arguably at a post-Cold War low point. Ties with China aren’t much better -- not least after Monday’s Department of Justice indictment of five Chinese officials for conducting espionage against the United States. Neither energy deals nor military exercises, in themselves, are designed to provoke a response from Washington. But the broad tightening of Russian and Chinese ties is a trend that the Obama administration will assuredly watch carefully.