President Xi Jinping of China on Friday offered firm support to President Vladimir V. Putin of Russia in the Kremlin’s showdown with the West over Ukraine, strengthening a relationship that presents a continuing challenge to the United States’ dominance on the world stage.

In a highly choreographed display of solidarity, the two leaders met in Beijing ahead of the opening ceremony of the Winter Olympics, the first meeting that Mr. Xi has held in person with a foreign counterpart in nearly two years.

China sided with Russia on one of its key security demands: an end to NATO expansion to the east and closer to Russia’s borders.

“The sides oppose further enlargement of NATO and call on the North Atlantic Alliance to abandon its ideologized Cold War approaches,” the statement said.

The meeting comes at a moment of escalating tensions between the West and Russia over Ukraine. Mr. Putin has amassed more than 100,000 troops to his neighbors north, south and east in what NATO allies view as a menacing prelude to an attack.

In a lengthy joint statement, China accused the United States of stoking protests in Hong Kong and encouraging independence in Taiwan, while Russia said the United States was playing a similarly destabilizing role in Ukraine.

“Russia and China stand against attempts by external forces to undermine security and stability in their common adjacent regions,” according to the 5,300-word joint statement released by the Kremlin. It said both nations “intend to counter interference by outside forces in the internal affairs of sovereign countries under any pretext, oppose color revolutions and will increase cooperation in the aforementioned areas.”

China has said that the world should not be divided into the kind of power blocs that defined the era when the Soviet Union and United States were the two dominant superpowers.

Although the intention behind the troop buildup remains uncertain, the Kremlin has accused the United States of exaggerating the threat of an invasion and of raising tensions by deploying its own troops to Eastern Europe. This week, Mr. Putin said the United States was trying to goad the Kremlin into action and complained that the West had ignored Russia’s demands for security guarantees.

In scenes initially shown on Russian state television, Mr. Putin greeted Mr. Xi on a red carpet at the government guesthouse in western Beijing, raising his hand in greeting. The Chinese leader responded, through a translator: “Hello! I’m very glad to see you.”

Mr. Putin told him that the Chinese-Russian relationship had “taken on a truly unprecedented character.” “It is an example of a dignified relationship that helps each of us develop while supporting each other’s development,” Mr. Putin said.

After their meeting, Mr. Putin will attend the opening ceremony of the Winter Olympics, as the most prominent of nearly two dozen world leaders whose attendance has blunted the impact of a “diplomatic boycott” by President Biden and other leaders of democratic nations.

Despite extraordinary measures both men have taken during the coronavirus pandemic, neither leader wore a mask as they greeted each other.

In the days leading up to the meeting — the 38th between the two leaders — Beijing expressed support for Mr. Putin’s grievances and it joined Russia to try to block action on Ukraine at the United Nations Security Council.

Although not a party to the conflict, the Chinese government has viewed the showdown as a test of American influence and resolve that could distract Mr. Biden from his administration’s focus on China as the pre-eminent strategic rival of the 21st century.

Any new Chinese promises of economic and political support for Mr. Putin could undermine Mr. Biden’s strategy to ostracize the Russian leader for the military buildup. They could also signal a tectonic shift in the rivalry between the United States and China, with possible reverberations from Europe to the Pacific.

Mr. Xi and Mr. Putin on Friday signaled that their countries would work to establish closer ties on trade, diplomacy and security.

“Friendship between the two states has no limits,” the pair said in their joint statement.