They visited a hockey rink in Beijing and the panda enclosure at the Moscow Zoo. They shared blinis layered with caviar in Russia and, reciprocally, the popular variant in China, jianbing. They have shared birthday cakes and exchanged toasts with shots of vodka, while demurring that neither would dare go overboard with the stuff.
For more than a decade, Xi Jinping of China and Vladimir V. Putin of Russia have forged a respectful, perhaps even warm relationship, reflecting the deepening ties between two world powers that share common cause against American military and economic might.
The invasion of Ukraine could upend all that — or forge, in diplomatic isolation, an alliance that reshapes the world order in the 21st century.
Three days into the conflict, it seemed clear on Sunday that Mr. Putin’s expectation of a quick subjugation of Ukraine was foundering. Ukrainian resistance slowed or stalled Russia’s forces, while Western nations sharply escalated economic pressure on Russia, which was looking almost totally isolated.
Mr. Putin’s attack on Ukraine has forced Mr. Xi into what Kevin Rudd, the Australian ex-prime minister who was once a diplomat in Beijing, called an “impossible balancing act” between his personal camaraderie with the Russian leader and the potential for blowback for China, should it be seen as endorsing an invasion condemned by most of the world.
On Friday, Mr. Xi spoke by telephone with the man he called his “best friend” in 2019, but stopped far short of endorsing the assault on Ukraine. He said all countries should “abandon a Cold War mentality,” and he expressed support when Mr. Putin told him he would seek a negotiated resolution to the war, according to the Chinese government’s summary of the call.
But there is no sign that Mr. Xi did anything to ward off the invasion, if he knew it was coming. His senior advisers rebuffed American requests to use China’s influence with Mr. Putin to discourage an attack; instead, China shared the Americans’ intelligence with the Russians and accused the United States of trying to sow discord, according to American officials.
For China, the costs of Mr. Putin’s adventurism could be high.
“I don’t think this is good for anybody,” said Wang Huiyao, president of the Center for China and Globalization, a research organization in Beijing that advises the government. “Conflict is not a solution, and China doesn’t want to see things deteriorate.”
China has deep ties with Europe and the United States that it cannot afford to sever, despite growing tensions in those relationships. The Ukraine invasion has rattled Chinese stock markets and threatens to roil the global economy during an important political year for Beijing that is expected to end with an extension of Mr. Xi’s rule.
The international furor over Ukraine — and the diplomatic isolation Mr. Putin is expected to face — could also serve as a warning of what Mr. Xi can expect if he uses force to subdue Taiwan, the self-governing democracy that China claims as its territory.
Mr. Putin, for his part, appears to be banking on China’s support over Ukraine — explicit or not — in the face of punitive measures that the United States and others have already begun to impose.
China has already lifted some restrictions on Russian wheat imports, but it has yet to indicate whether it will abide by American and European sanctions meant to restrict Russia’s access to capital.
“It’s really going to be an acid test,” said John Culver, a retired Central Intelligence Agency officer who studied China. “It’s going to demonstrate whether China would really support Russia and provide economic support in violation of sanctions, or even face sanctions itself.”
Only three weeks ago, on the eve of the Winter Olympics in Beijing, Mr. Putin and Mr. Xi met for the 38th time since Mr. Xi became China’s leader, declaring that the friendship between their countries had “no limits.”
Outside their inner circles, it is not known whether Mr. Putin disclosed his plans for Ukraine to Mr. Xi then. A Chinese Foreign Ministry spokeswoman, Hua Chunying, suggested that he had not.
Now, Mr. Putin has forced China into the awkward position of explaining how the invasion does not violate the principle of respect for national sovereignty that is, officially, a pillar of China’s foreign policy.
“They must feel like they’ve been played,” Mr. Culver said of the Chinese leaders.
China’s uncertainty over the issue has been clear in the statements of officials like Ms. Hua, who declined to call the invasion an invasion and sought to shift the blame for it to the United States. China may consider Taiwan an unconquered province, but it has explicitly recognized Ukraine as a sovereign nation, one with which it has close economic ties.
However the war ends, it has already underscored how important — and complex — the relationship between Mr. Xi and Mr. Putin has become.
It has been shaped by striking biographical parallels, but also by differences that could test their “no limits” pledge.
Mr. Putin and Mr. Xi were born only eight months apart — Oct. 7, 1952, and June 15, 1953, respectively — and both were children of Communist powers that rose out of the catastrophic convulsions of war and revolution. They idolized their fathers, veterans of those conflicts, and were inculcated in the Marxist-Leninist view of world affairs.
Mr. Xi’s father oversaw China’s cadre of Soviet experts and visited the Soviet Union in 1959, bringing back gifts for his son that were later destroyed during the Cultural Revolution, according to Joseph Torigian, an assistant professor at American University and author of a forthcoming biography of Mr. Xi’s father, Xi Zhongxun.
Mr. Xi has recalled in interviews that he grew up reading Russian literature and was inspired by a minor character in “What Is to Be Done?” the 1863 novel by Nikolai Chernyshevsky, who sleeps on a bed of nails.
“They have very similar views of the role of history in politics and how attacks on their own history are seen as treacherous and dangerous,” Mr. Torigian said of the two leaders.
Both ended up in government service, Mr. Putin as an intelligence officer in the K.G.B. and Mr. Xi as a regional party functionary after the political rehabilitation of his father, who had been imprisoned during the Mao era, accused of spying for the Soviets.
Sergey Alexsashenko, who was a deputy chairman of the Russian central bank during Mr. Putin’s rise in the 1990s, said there was a key difference between the two leaders’ biographies.
Mr. Putin, he noted, served in the intelligence service when the Soviet Union was entering its inexorable decline in the 1970s and 1980s, while Mr. Xi joined the government ranks as China’s transformation from impoverished nation to global economic powerhouse began.
“For Xi, the history of China while he’s a mature man is a history of success,” Mr. Alexsashenko said. “He wants to move ahead with this rebuilding for the future. For Putin, all good was in the past.”
The experience that most closely binds them is the global political turmoil of 1989, beginning with the protests in Tiananmen Square in Beijing that China crushed, followed by the demonstrations that toppled the Soviet Union’s satellite states in Europe.
Mr. Xi, then an official in Fujian Province, warned in a party newspaper that democracy without restriction meant “no constraints or sense of responsibility.”
Understand Russia’s Attack on Ukraine
What is at the root of this invasion? Russia considers Ukraine within its natural sphere of influence, and it has grown unnerved at Ukraine’s closeness with the West and the prospect that the country might join NATO or the European Union. While Ukraine is part of neither, it receives financial and military aid from the United States and Europe.
Mr. Putin was by then a lieutenant colonel at the K.G.B.’s Dresden outpost, watching helplessly as protesters ransacked the local headquarters of the Stasi, East Germany’s secret police. He was forced to retreat to the Soviet Union, which collapsed two years later, creating new borders that he is now essentially trying to erase.
Both leaders have spoken often about the lessons of that period, reinforcing what they see as the need for a strong state hand to control popular sentiment.
In a speech in 2013, Mr. Xi denigrated the last Soviet leader, Mikhail S. Gorbachev, for letting the Soviet Union fall on his watch, something Mr. Putin has called the “greatest geopolitical catastrophe of the 20th century.”
“In the end,” Mr. Xi said, “nobody was a real man.”
Mr. Putin’s pivot toward China began under Mr. Xi’s predecessors. He settled a border dispute that had flared into a short war between the Soviet Union and China in 1969, and he eased visa restrictions that allowed for a trade boom across their border.
When Mr. Xi came to power a decade ago, the entente between the countries accelerated into a deepening relationship that has overcome decades of division and suspicion. Trade has skyrocketed, reaching $146 billion last year. The two militaries train together and conduct joint air and naval patrols along China’s coast.
“Even though the bilateral relationship is not an alliance, in its closeness and effectiveness this relationship even exceeds that of an alliance,” Mr. Xi told his counterpart during virtual talks in December, according to Mr. Putin’s foreign policy adviser Yuri V. Ushakov.
That relationship seemed to reach a new peak at the Olympics. After their meeting, the leaders issued a lengthy joint statement that raised alarms in Washington.
It was the first time China had explicitly endorsed Russia’s demand for a halt to NATO expansion, though it had criticized previous NATO applications by individual countries, including Montenegro and North Macedonia.
The two leaders also vowed to resist American-led efforts to promote pluralistic democracy and said they would fight foreign influence under the guise of what both call “color revolutions,” after the popular uprisings in former Soviet republics like Ukraine and Georgia.
Even so, Mr. Xi now appears uncomfortable with how Mr. Putin has chosen to bring Ukraine to heel. “I think the Chinese are going to have balance how much they want to invest in Putin,” Mr. Culver, the former intelligence officer, said, “and how much it’s going to cost them strategically.”
Anton Troianovski, Chris Buckley and Claire Fu contributed reporting or research.