– With a dose of mystery and the flair of a showman, North Korea’s young leader, Kim Jong Un, used his debut as an international statesman on Wednesday to present himself as confident, reasonable — and willing to bargain.

Kim’s surprise two-day visit to Beijing, his first known trip abroad since taking power, was effectively a reminder of how much he has set the agenda in the crisis over his nation’s nuclear arsenal — and of what a strong hand he has going into talks, first with President Moon Jae-in of South Korea next month and later with President Donald Trump.

Kim has yet to say what concessions he is willing to make, or what he may demand from the United States in return. But he continued to dominate the diplomatic process, reaffirming his willingness to meet with Trump and repeating his vague commitment to the denuclearization of the Korean Peninsula in talks with President Xi Jinping of China, according to Xinhua, the Chinese state news agency.

During Trump’s first year in office, Kim raced ahead with breakthrough tests of a hydrogen bomb and missiles capable of hitting the U.S. mainland. Then he abruptly changed course and used the Winter Olympics to seize the initiative, surprising the world with a rapprochement with the South and then an offer to meet with Trump.

Through it all, the Trump administration has been largely relegated to reacting and catching up to Kim. And so it was again this week, when Kim suddenly showed up in China on an armored train and was shown beaming next to Xi, whose cooperation has been critical to Trump’s strategy of “maximum pressure” on the North.

In images and in words, Kim and Xi signaled that they had repaired the relationship between their countries, which had soured as Kim had accelerated his nuclear program and Xi had responded by endorsing — and enforcing — more punishing sanctions proposed by the United States.

“The friendship between North Korea and China that was personally created and nurtured together by former generations of leaders from both our sides is unshakable,” Kim told Xi, according to Xinhua.

It is too soon to say whether the meeting marks a softening of China’s posture toward Kim Jong Un or of its commitment to international sanctions against North Korea. But the visit served to highlight Beijing’s unique leverage over North Korea, even as Trump is threatening China with a trade war.

Trump can talk about maintaining “maximum pressure” on the North, but ultimately China — the North’s main trade partner — still decides what that means, because it can choose how strictly to enforce sanctions.

“China is saying to the United States and the rest of the world: Anyone who wants a deal on anything on the future of the Korean Peninsula, and certainly something which deals with nukes, don’t think you can walk around us, guys,” Kevin Rudd, a former Australian prime minister who is on good terms with the Chinese leadership, said in Hong Kong on Wednesday.

If China decides to soften its stance on sanctions and act as North Korea’s protector, Kim will enter the talks with Trump in a considerably stronger position than he otherwise would have.

The Chinese government said it had briefed the White House on Kim’s visit, adding that Xi had sent a personal message to Trump. On Wednesday morning, Trump expressed optimism on Twitter about the potential for diplomatic success, saying there was “a good chance” that Kim would “do what is right for his people and for humanity.”

But there was little in the public accounts of Xi’s discussions with Kim to support such a positive assessment. Though Xinhua quoted Kim as saying he was open to talks with Trump and committed to denuclearization, North Korea’s own state media made no mention of either.