The leaders of China and Russia hailed each other as “old” and “dear” friends. They took swipes at the United States and depicted themselves as building a “fairer, multipolar world.” And they marveled at their countries’ “deepening” trust.

China’s top leader, Xi Jinping, used a Beijing-led conference of leaders from mostly developing countries on Wednesday to showcase his ambitions to reshape the global order, as the world grapples with a war in Ukraine and a crisis in Gaza. He cast his country as an alternative to the leadership of the United States. And he gave a prominent role to President Vladimir V. Putin of Russia, underscoring how central their relationship is to Mr. Xi’s vision.

The event, the Belt and Road Forum, is centered on China’s signature foreign policy initiative, which aims to expand Beijing’s influence abroad with infrastructure projects. Mr. Putin was treated as the guest of honor and often pictured by Mr. Xi’s side. The two leaders also met for three hours in Beijing on Wednesday.

While Mr. Putin and Mr. Xi huddled, President Biden landed in Israel on a visit aimed at preventing the war between Israel and Hamas from spreading. Though Mr. Xi did not publicly remark on the war, Mr. Putin, at a news briefing, blamed the United States for increasing tensions in the Middle East by sending warships to the region. He said that such regional conflicts were “shared threats that only strengthen Russo-Chinese relations.”

In Mr. Putin, Mr. Xi has a like-minded partner driven by shared grievances toward the West who is willing to push back against what they both perceive as American hegemony. Mr. Xi sought to tout China as a force for stability in the world, with Mr. Putin alongside him — never mind that Russia upended European security when he launched an invasion of Ukraine 21 months ago.

“Ideological confrontation, geopolitical rivalry and bloc politics are not a choice for us,” Mr. Xi said in a speech at the opening of the forum at the Great Hall of the People in Beijing.

“What we stand against are unilateral sanctions, economic coercion and decoupling and supply chain disruption,” Mr. Xi said, clearly referring to efforts by the United States and its Western allies to pressure China. Washington and Beijing are engaged in an intense rivalry over trade, technology and the status of Taiwan, and China has protested bans imposed by the United States on exports of semiconductors to China.

Mr. Xi’s friendly display with Mr. Putin at the Beijing forum reaffirms a partnership, not long ago hailed by the leaders as having “no limits,” that has contributed to the splintering of countries into opposing blocs. Mr. Putin, at the start of his meeting with Mr. Xi on the sidelines of the conference, said that China and Russia needed to coordinate their foreign policies more closely, given what he called the “current difficult conditions.”

The conference was virtually absent of European Union countries, largely because of the divisiveness of Russia’s war in Ukraine. Prime Minister Viktor Orban of Hungary, an authoritarian-leaning friend of Mr. Putin and Mr. Xi, was the only European Union leader to attend.

Represented instead were nearly 150 developing nations. China has disbursed close to $1 trillion through the Belt and Road initiative, largely in loans, to build power plants, seaports, and other infrastructure across Asia, Africa and Latin America, but some countries are finding their debt obligations onerous.

As for Mr. Putin, his trip has yet to yield any new economic deals with China. But it has already brought diplomatic dividends for him, allowing the Russian leader to present himself as a global power broker despite Western efforts to isolate him. He also met with other Asian leaders in Beijing.

“The forum has clearly shown that Russia remains a massive country with massive resources, and that they are very far from isolation,” said Artem Lukin, an international relations professor at Far Eastern Federal University, in Vladivostok, Russia. “Asia, and the Global South in general, are clearly showing that the war in Ukraine is not their concern, and that they are more interested in doing business with Russia.”

At the same time, Mr. Putin also sought to signal his geopolitical autonomy from China, his country’s more powerful neighbor. He outlined Russia’s own grandiose infrastructure plans in the region and called for foreign investment, without stating plans to join China’s existing projects. Later on Wednesday, he called the two visions “complementary.”

The question of how far China and Russia’s alignment extends has come into focus in the question of how the world should respond to the humanitarian crisis in Gaza, which is becoming another wedge between Washington and Beijing.

Beijing and Moscow have avoided condemning Hamas for its attack on Israel this month. They have criticized Israeli airstrikes in Gaza and called for a revival of talks for a Palestinian state.

For China, its criticism of Israel reflects its rising assertiveness and desire to curry favor with countries in the Middle East, analysts say. China has tried to play a bigger role in the Middle East to fill a vacuum left by the exit of U.S. troops, most notably in Afghanistan. In March, China helped broker a deal to restore diplomatic relations between Saudi Arabia and Iran, two archrivals. Beijing has also offered to mediate between Israelis and Palestinians, though efforts have failed to gain traction.

“The crux of the issue lies in the fact that justice has not been returned to the Palestinian people,” China’s foreign minister, Wang Yi, said last week in a phone call with Celso Amorim, an international affairs adviser to President Luiz Inácio Lula da Silva of Brazil.

On Sunday, Mr. Wang told his Saudi counterpart, Prince Faisal bin Farhan, that Israel’s retaliation in Gaza had “already gone beyond self-defense.” He also called on Israel to halt the “collective punishment of the people of Gaza.”

The pointed remarks signal a shift away from China’s stated policy of noninterference in another country’s internal affairs. China typically treads carefully when it comes to conflict in other countries, often opting for neutrality and anodyne statements about supporting peace. The strategy provides China more flexibility by limiting its adversaries. It also allows China to deflect criticism about its domestic policies, such as its crackdown on freedoms in Hong Kong and human rights abuses in the regions of Tibet and Xinjiang.

China’s stance will play well in the Muslim world, where it has faced some criticism in the past over its treatment of Muslim Uyghurs in Xinjiang. Historically, China has maintained closer ties to the Palestinians. It recognized a Palestinian state in 1988, four years before establishing diplomatic relations with Israel. Chinese support for the Palestinian cause goes back to the days of Mao Zedong, who saw kinship in the struggle with Western-backed powers.

“They’re doing this as a way to signal to the Global South that China will support those countries in a way that they probably shouldn’t expect Western countries in general, and the U.S. in particular, to support them,” said Jonathan Fulton, a nonresident senior fellow with the Atlantic Council.

Olivia Wang contributed reporting.