In the middle of January, while Donald Trump and his aides were devising a tale of American Carnage to be delivered a few days later to a modestly sized inauguration crowd in Washington, Chinese leader Xi Jinping was addressing a more rarefied audience at the World Economic Forum in Davos, Switzerland. Trump’s speech would be dark and angry. Xi’s was hopeful and assured — a high-minded paean to openness and cooperation and global community. It pledged that China would act not just for its own well-being, but for the well-being of people everywhere, before concluding with a call to “march arm in arm toward a bright future.”

Xi’s upbeat message might have seemed surprising given events of the previous months. The incoming U.S. president had launched his campaign declaring, “You have a problem with ISIS. You have a bigger problem with China,” and gotten ferocious applause during the race proclaiming, “We can’t continue to allow China to rape our country.” He had threatened to overturn the understanding that underpinned the two countries’ diplomatic relationship, the One China policy, and that goes to the heart of Beijing’s most acute national-security concern. He had broken protocol to take a call from the president of Taiwan. His most influential adviser, Steve Bannon, had blithely expressed “no doubt” that America would go to war with an “arrogant” and “expansionist” China by 2025. His nominee for secretary of State, Rex Tillerson, had hinted at a belligerent new approach in the South China Sea.

But in the run-up to Inauguration Day, another dynamic — far less frightening from the Chinese government’s perspective — had started to become apparent. With skillful handling, Xi and his officials could not only manage Trump’s bluster and bravado, they could turn his posturing to their own considerable advantage.

Before long, Xi, by doing nothing more than delaying a phone call, had compelled Trump to reverse course on the One China policy. (“The president always gets something,” White House Press Secretary Sean Spicer insisted of the reversal, but the only apparent concession from China since Election Day had been suddenly favorable treatment of Trump Organization trademark requests.) Secretary of State Tillerson had shown up in Beijing and parroted Chinese talking points before a meeting, and then parroted them again afterward for good measure. (“He was aware of his word choice,” Tillerson’s spokesman later confirmed, while China’s state-run media crowed that the talking points had never been used by anyone in the Obama administration.) And soon enough, Xi had gotten just the sort of personal gesture he wanted: an invitation to meet with Trump at Mar-a-Lago this week, for a two-day encounter heavy on flattering photo ops and light on bothersome media interaction.

Ahead of Xi’s arrival on Thursday, the dynamic is playing out again. Trump has issued the usual tough-guy ultimatums. “The meeting next week with China will be a very difficult one in that we can no longer have massive trade deficits and job losses,” he tweeted. “Well, if China is not going to solve North Korea, we will,” he said in an interview. “The clock has now run out, and all options are on the table,” a White House official added after another North Korean missile test this week.

Xi knows how such ultimatums should be handled. He has prepared the ground through informal channels, with his adept ambassador to Washington cultivating the ever-self-confident Jared Kushner and working around the more watchful diplomats and policy makers in the rest of the U.S. government (who mostly objected to the Mar-a-Lago meeting happening at all). He has crafted “a package of pledges designed to give the U.S. president some ‘tweetable’ promises to present as victories,” as the Washington Post put it, shiny objects that will placate Trump without ceding real ground. As the White House gloats in triumph, the Chinese will be happy to play along. And Xi will go home having gotten what he needs to strengthen his domestic position: praise for skillful handling of Washington and credit for exposing his American counterpart as a “paper tiger.”

For all the well-warranted focus on Russia these days, Washington’s approach to China remains the most consequential issue in American foreign policy. Even before Trump’s victory, the U.S.-China relationship was at a challenging moment, with friction growing on various issues despite interdependence in everything from economics to environmental challenges. The White House’s “malevolence tempered by incompetence” may be America’s salvation when it comes to key pieces of Trump’s domestic agenda. But in foreign policy, arrogance compounded by ignorance could do irreversible damage.

“I beat China all the time,” Trump has boasted. “All the time.” Xi has no reason to disabuse him of that notion — though events could always do so on their own. What happens if Trump discovers that gestures of Chinese cooperation in addressing North Korea’s nuclear-weapons program can’t necessarily stop Kim Jong-un from testing missiles that could hit California? Or that commercial announcements made with great fanfare won’t restore America’s manufacturing sector?

Xi will try to avert any breakdowns: He has an interest in stability ahead of a November Communist Party Congress that will launch his second term. So, starting at Mar-a-Lago, he will play to Trump’s narcissism and political needs while taking advantage of the strategic opportunity at hand.

And for China’s leaders, the opportunity is significant. In Trump, they suddenly have an American president who sees the world in a way they can exploit — and has expressed only disdain for the rules-based liberal order his predecessors have worked to uphold. He cares little about how other powerful governments treat either their own people or less powerful countries they consider within their sphere of influence. He shows no interest in offering an alternative approach for American economic leadership in Asia after scrapping the Trans-Pacific Partnership trade agreement, leaving it to Beijing to set the rules instead. Even while talking tough about China this week, he included a gratuitous swipe at alliances — exactly the kind of comment that makes our allies worry that, especially in the face of a rising China, American promises are no longer worth much.

Trump is happy to sacrifice long-term advantages for the sake of a deal that serves his own narrow interests in the short term: Like a customer in a pawnshop, he is so desperate for an immediate payout that he doesn’t worry about the ultimate value of what he’s giving up. Xi, meanwhile, can seamlessly claim the role of responsible world statesman. At Davos, he had only to say the right words to elicit cheers from the crowd. Following another speech in support of the Paris climate accord the next day, The Economist deemed him “the global grown-up” of our time. He wins acclaim for celebrating openness and cooperation abroad even while continuing to restrict freedoms and crack down on dissent at home.

Most important, Trump allays one of the biggest sources of anxiety for China’s Communist Party leaders: the security of their position. Since 2008, they have held up the financial crisis as proof of the bankruptcy of the American economic model; now they can point to disarray in American democracy to deny the superiority of the political model — and bolster their legitimacy by extension. Xi can worry less about making the case for his own leadership. Trump is making it for him.