BEIJING — Amid the pomp that President Xi Jinping of China is bestowing upon his visiting American counterpart, President Trump, it’s hard not to see two leaders — and two countries — heading in very different directions.

Mr. Xi emerged from last month’s Communist Party Congress the undisputed master of the Middle Kingdom. “Xi Jinping Thought” was enshrined in the Constitution — an honor previously granted only to Mao Zedong and Deng Xiaoping. Breaking with precedent, Mr. Xi neglected to anoint a successor — a big hint that he feels emboldened to extend his rule beyond the second five-year term he has just begun. The Economist heralded Mr. Xi with an honorific usually reserved for America’s president: the world’s most powerful man.

Mr. Trump stepped off Air Force One in Beijing on Wednesday with historically low job-approval ratings, just hours after suffering a shellacking in off-year elections. His credibility is cratering abroad — polls have shown a drop in confidence in American leadership.

As the personal trajectories of Mr. Trump and Mr. Xi diverge, so too does the focus of their leadership. While Mr. Trump is obsessed with building walls, Mr. Xi is busy building bridges.

At the World Economic Forum in January, Mr. Xi proclaimed China the new champion of free trade and globalization. His “One Belt, One Road” initiative — with funding from the made-in-Beijing Asia Infrastructure Investment Bank — will invest $1 trillion in linking Asia with Europe through a network of sea routes, roads, railways and, yes, bridges. China will gain access to resources, export its excess industrial capacity and peacefully secure strategic footholds from which to project power.

The Trump administration has belittled the United Nations, withdrawn from the Trans-Pacific Partnership trade agreement, jettisoned America’s commitment to the Paris climate accord, tried to renege on the nuclear deal with Iran, questioned America’s core alliances in Europe and Asia, disparaged the World Trade Organization and multicountry trade deals, and sought to shut the door on immigrants.

Mr. Xi? He has grabbed leadership of the climate-change agenda, embraced the World Trade Organization’s dispute-resolution system and increased China’s voting shares at the World Bank and International Monetary Fund. Beijing is forging ahead with a trade pact that would include the major Asian economies plus Australia and New Zealand, but not the United States. China is now one of the leading contributors to the United Nations budget and peacekeeping operations. And Mr. Xi is making a determined play to attract the world’s cutting-edge scientists and innovators to China.

At home, Mr. Xi is making strategic investments that could allow China to dominate the 21st-century global economy, including in information technology and artificial intelligence — where, Eric Schmidt of Google has warned, China is poised to overtake the United States in the next decade. Mr. Xi is all-in on robotics, aerospace, high-speed rail, new-energy vehicles and advanced medical products.

Mr. Trump’s “strategic” investments — in coal and a quixotic effort to bring back manufacturing lost to automation — would make the United States the champion of the 20th-century economy.

All of this positions China to become, in Mr. Xi’s words, “a new choice for other countries” and the principal arbiter of something long associated with the United States: the international order. China has a profound stake in that order and a globalized world: It needs access to advanced technology and the export markets upon which its growth depends.

The contradictions at the heart of China’s enterprise could still prove to be its undoing. Beijing continues to fence off key sectors of its economy to foreign investment. It imposes draconian requirements on foreign companies — like requiring them to take on a Chinese partner and hand over their technology and intellectual property — that other countries do not impose on Chinese companies.

Mr. Xi’s ability to sustain the outward projection of Chinese influence is also challenged by his country’s systemic weaknesses. A mountain of debt. Rising inequality. Slowing growth, dragged down by an aging population, lower productivity and inefficient state-owned enterprises. Poisonous air and scarce water. And an increasingly repressive system that may appeal to fellow authoritarians but not to Chinese citizens.

But China’s shortcomings may not matter in the absence of a compelling alternative. I’d never bet against the United States, but if the Trump-led retreat into nationalism, protectionism, unilateralism and xenophobia continues, China’s model could carry the day.

The world is not self-organizing. And American stewardship of the international order advanced liberal values and progressive norms — democracy, human rights, freedom of speech and assembly, protections for workers, the environment and intellectual property. By abdicating the leadership role it has played since World War II, the United States is giving the terrain to others who will do the organizing on the basis of their values, not America’s.

Mr. Xi is not shy about who that someone else will be. With Mr. Trump ceding ground to China, the liberal international order that defined the second half of the 20th century could give way to an illiberal one.