The United States, China’s largest trading partner but also its greatest geopolitical rival, faces an election that threatens domestic instability. A Donald Trump victory would confirm to many Chinese the inherent weakness of American democracy. A Hillary Clinton victory, on the other hand, would force Beijing to deal with a politician widely viewed as unfriendly, and sometimes even hostile, to Chinese interests.

One might think that China would therefore welcome a Trump presidency. Yet conversations over the past six months with roughly half-a-dozen mid-ranking and high-ranking Chinese officials, as well as with sources afforded insight into the thinking of top Chinese policymakers, show that many in the Chinese political class grudgingly support Clinton — precisely because they believe a Trump presidency would be a disaster for the United States. Although on their face, many of Trump’s economic, political, and military policies would be far more beneficial to China than Clinton’s, the Chinese elite seem to prefer Trump’s opponent because they feel she would be better for the United States, its place in the world, and thus global stability, which remains of great importance to Beijing.

“While China’s elites scrupulously avoid taking public positions on internal affairs of other countries — especially U.S. politics — their incessant concern for stability, international as well as domestic, moves many to believe that Clinton, not Trump, would be better for China,” said a source familiar with Chinese leaders’ thinking, who asked to speak anonymously. And a source close to China’s leaders, who also asked to speak anonymously, said that although Beijing reaps huge public relations gains from Trump’s meteoric rise and what it says about the state of American democracy, “the perfect outcome is for [Trump] to lose narrowly.”

This would seem to run counter to China’s interests. Despite Trump’s inveterate China-bashing, many of his proposed policies could actually benefit China. His desire to dismantle America’s alliance structure in Asia would greatly improve Beijing’s military position with regards to its rival Japan. Unlike Clinton, who has vociferously criticized China’s human rights violations, Trump appeared to applaud Beijing’s 1989 slaughtering of student protestors in Tiananmen Square during a 1990 interview with Playboy. (In a March 2016 GOP debate, he said he wasn’t endorsing Beijing’s behavior, but proceeded to call the protests “a riot,” echoing language used by the ruling Chinese Communist Party.) And while Trump touts himself as a masterful deal-maker, Chinese bureaucrats — themselves known internationally for tough negotiating — seem to regard Clinton more seriously. “Clinton will be very tough on China,” a senior official complained, earlier this year. Yet when asked about Trump, the official failed to stifle a grin. “We can handle Trump,” the official said.

But for many of Beijing’s political elite, the risks and uncertainties of a Trump presidency outweigh the benefits. Even though China would gain tremendously if Trump weakened U.S. commitments and alliances in Asia, they mostly believe Clinton is ultimately better for China, the source familiar with Chinese leader’s thinking said. Trump’s isolationism and his disregard for multilateral institutions would leave an international power vacuum that Beijing is not ready to fill. One influential Chinese academic, who asked to speak anonymously so he could talk freely about the election, told Foreign Policy that a Trump victory “would be a heavy blow against global governance and globalization,” two international trends that have benefited China immensely. The economic pain from a Trump presidency’s repudiation of global trade, and its mishandling of the U.S. economy, could further decelerate China’s already slowing economic growth, and by doing so, weaken the party’s hold on power.

Moreover, the party’s grip on power is never as strong as it appears from the outside. Many see President Xi Jinping as a serenely confident leader who has consolidated power via an anti-corruption drive, the appointment of himself to various “leading groups,” and the recent conferral of “core” leader status at a Party plenum. Yet there’s an element of fragility to Xi’s hold on power. China’s economy is dealing with worrying high levels of debt and, in some cities, real estate markets that many fear are bubbles. Official corruption, and discontent over elements of Party rule, still simmer throughout the country. A Trump victory could inject unwanted uncertainty and instability into China’s most important bilateral relationship.

To be sure, speculating about what China’s political class feels about the U.S. election — especially what the 24 men and one woman who make up China’s secretive ruling Politburo feel — is fraught. What Xi personally feels is even more difficult to glean. What’s clear, however, is the massive propaganda victory Beijing gains from the effect Trump has on American democracy’s image abroad. “They see this as what popular democracy brings,” said the source close to China’s leaders. “Le Pen in France, the rise of the far right in Germany, Nigel Farage in the United Kingdom, and Trump — a bunch of nutcases.”

But the futures of China and the United States are too interconnected for Schadenfreude to dominate. “If I were America’s enemy, I would hope Trump is elected .. he will leave the U.S.’s domestic and foreign policies in disarray,” Ren Xiao, a former diplomat and a professor at Fudan University in Shanghai, told the journalist Vincent Ni. “But if I were America’s friend, I would think that Hillary would be a better president.” For Beijing’s political elite, friendship and cooperation — at least, the desire for predictability and stability — seems to outweigh whatever glee would greet the weakening of American interests.