BEIJING — Chinese President Xi Jinping bluntly told President Donald Trump on Thursday that if the two countries mishandle their dispute over Taiwan, they risk “clashes and even conflicts,” an unusually direct warning that overshadowed Trump’s attempt to cast his three-day visit as a triumph of personal diplomacy.

The warning was delivered behind closed doors at the Great Hall of the People but relayed by Chinese Foreign Ministry spokesperson Mao Ning in a post on X after the meeting. “The Taiwan question is the most important issue in China-U.S. relations,” she wrote, quoting Xi. “If it is handled properly, the bilateral relationship will enjoy overall stability. Otherwise, the two countries will have clashes and even conflicts, putting the entire relationship in great jeopardy.”

Trump had opened the summit on a starkly different note, telling Xi in brief public remarks: “You’re a great leader. Sometimes people don’t like me saying it, but I say it anyway, because it’s true.” He added, “It’s an honor to be your friend,” and said the relationship “is going to be better than ever before.” Later, in an interview with Fox News’ Sean Hannity, Trump said Xi “would like to be of help” in negotiating an end to the war in Iran and reopening the Strait of Hormuz to oil shipments.

Secretary of State Marco Rubio, who was traveling with Trump, told NBC News that U.S. policy toward Taiwan was “unchanged” but cautioned that it would be “a terrible mistake” for China to take the self-ruled island by force. China claims Taiwan as part of its territory and has objected to a $11 billion U.S. arms package the Trump administration approved but has yet to begin fulfilling.

Xi, in his own opening remarks, expressed hope that the U.S. and China could avoid conflict. “Whether the two countries can transcend the ‘Thucydides Trap’ and forge a new model for relations between major powers,” he said, using a term popular in foreign policy circles to describe the likelihood of war when a rising power challenges an established one.

The meeting was surrounded by elaborate ceremony. After a welcome featuring cannon fire, a band playing both national anthems, and hundreds of children waving flags, Xi took Trump on a tour of the Temple of Heaven and hosted a state banquet. In his toast, Xi said that “achieving the great rejuvenation of the Chinese nation and making America great again can go hand in hand” and that “we can help each other succeed and advance the well-being of the whole world.” Trump, in his own toast, called the day “fantastic” and said Xi would make a reciprocal visit to the White House on Sept. 24 — a date not previously announced.

The White House readout of the meetings said both leaders discussed expanding market access for American businesses and increasing Chinese investment in the United States. On Iran, the readout said both sides agreed the Strait of Hormuz must remain open, and that Xi opposed any tolls on vessels crossing it. Trump told Fox that Xi had committed to buying 200 Boeing jets, though that claim was not independently confirmed.

China is the largest buyer of Iranian oil, and Rubio said in a separate Fox interview that the administration would press Beijing to use its influence, noting that energy prices are spiking globally and “economies are melting down because of this crisis.” The White House also noted progress on stemming the flow of fentanyl precursor chemicals and on increasing Chinese purchases of U.S. agricultural products.

In Taipei, a spokesperson for Taiwan’s premier, Michelle Lee, said the government was “grateful” for Washington’s long-term support and viewed “all actions that contribute to regional stability and the management of potential risks from authoritarian expansion positively.”

Despite the pageantry, the summit yielded no breakthrough on the core disputes over Taiwan or Iran, and the Trump administration’s hope that personal rapport could bridge deep strategic divides met a firm Xi warning that the most sensitive question — Taiwan’s status — remains a potential tripwire for conflict.