President Donald Trump’s decision to agree to a historic face-to-face meeting with North Korean leader Kim Jong Un can be traced back to the savvy politicking of another leader entirely: South Korean President Moon Jae-in.

Moon, who has been in office just 10 months, played a pivotal role in setting up the potential summit. That’s a particularly impressive accomplishment for Moon given that he and Trump have at times clashed sharply about how aggressively to confront North Korea. Tensions got so bad that in September, Trump accused Moon of “appeasement.”

Trump is taking a very different line now, expressing an openness to talks with Kim that would have seemed unimaginable when the president threatened to “totally destroy” North Korea during a United Nations address in September.

Experts say the shift reflects the success of Moon’s persistent push for “anytime, anywhere” diplomacy with Pyongyang. The South Korean leader’s efforts got a major boost during the runup to the Pyeongchang Winter Olympics, when he and Kim got into high-level talks over North Korea’s participation in the games. Moon used the momentum from those talks to set the stage for an unprecedented US-North Korean summit.

“South Korea deserves the vast bulk of the credit for this summit offer,” Mintaro Oba, a former State Department official who worked on North Korea policy, told me. “This wouldn’t have happened without President Moon’s initiative and deftness in balancing engagement with North Korea and close coordination with the United States.”

Moon’s orchestration of this meeting has, at least for now, significantly diminished the chance of violent conflict breaking out between North Korea and the US and steered the relationship toward the kind of open-minded diplomacy that he has called for for decades.

He’s also managed to break the pattern of what some South Koreans call “Korea passing” — the way the big regional players like China, Japan, and the US at times exclude or sideline South Korea in talks about North Korea policy. Moon has managed to charm Trump after a period of stormy relations, and has ensured that South Korea is now playing an indispensable role in talks over denuclearizing North Korea.

But it’s also a risky gambit. Moon can bring the US and North Korea to the table, but he can’t force them into a deal. And if the negotiations fail, Kim and Trump might, in a worst-case scenario, decide that military force is the only option left.

South Korea’s leader thinks talking with North Korea is the key to peace

Moon, a 65-year-old former human rights lawyer, has spent years pushing for a diplomatic solution to the decades-long cold war between North and South Korea.

Moon first had a chance to put his vision into practice more than a decade ago, when he served as the chief of staff to Roh Moo-hyun, South Korea’s president from 2003 to 2008. Moon helped engineer the “Sunshine Policy” of approaching North Korea with dialogue and economic aid, which led to, among other things, a substantial reduction in tensions between the countries and a boom in South Korean tourism in the North.

Roh’s successors took a harder line on North Korea. When Moon campaigned for the presidency last year, he proposed a return to the Sunshine framework as a way to reduce tensions with the North. The platform was playfully nicknamed “Moonshine” policy.

After he took office, Moon quickly proposed talks with North Korea, and his administration continually indicated that under the right circumstances he would meet with North Korea “anytime, anywhere.”

“Talking for the sake of talking is enough for him, just to get the ball rolling,” James Person, the research director at the US-Korea Institute, told me.

Moon also bristled at Trump’s threats of taking unilateral military action against North Korea. “No one shall take a military action on the Korean Peninsula without South Korean consent,” he said in August. “We will prevent war whatever it takes.”

While Moon and Trump disagreed sharply on how to approach North Korea, analysts say that Moon managed to stay on Trump’s good side by staying cool in the face of Trump’s provocations — and using flattery.

“He has learned lessons from the Roh Moo-hyun era — that it does no good to his country to provoke the United States,” Lee Byong-chul, a senior fellow at the Institute for Peace and Cooperation in Seoul, told the New York Times. “If Roh was blunt and in-your-face, Moon is much more cautious and sophisticated. See the way he keeps giving credit to Trump for supporting inter-Korean ties.”

Moon got his first big opportunity to change the diplomatic game on January 1, when Kim said that he was interested in talking with South Korea about sending athletes to the Winter Olympics during his New Year’s Day speech. Moon leaped at the chance, and just a week later, the North and South held high-level talks at the Demilitarized Zone that separates the rival countries for the first time in about two years. North and South Korea agreed to march under a united flag at the Olympics and form a joint women’s ice hockey team.

Kim then decided to send a surprisingly high-profile delegation to attend the Olympics in February. He sent North Korea’s ceremonial head of state, Kim Yong Nam, and, most crucially, his sister Kim Yo Jong, to attend. Kim Yo Jong, a powerful official in North Korea and a close confidante of her brother, then invited Moon to the first inter-Korean summit in more than a decade.

Moon decided to leverage the opening by insisting that North Korea also reach out to the US if talks between North Korea and South Korea were going to proceed in any meaningful way. It worked.

When a South Korean delegation met with Kim in Pyongyang on Monday, Kim asked them to extend a verbal invitation to an in-person meeting with Trump on his behalf. On Thursday South Korean officials relayed the message to the White House — and Trump accepted.

Trump’s decision to meet with Kim was an extraordinary development, and a meeting would make history. The question is whether it will actually take place.

Moon’s plan could backfire

Trump’s decision to break tradition and meet Kim is a major coup for Moon. Moon has helped walk the US and North Korea back from the brink of war, and there seems to be some possibility, however small, that the two countries could strike some kind of deal that would further deescalate tensions.

But there are enormous limits to Moon’s ability to control the conversation once it actually gets underway.

Analysts say they’re concerned that Trump will have unrealistic expectations for what he can get North Korea to agree to during his meeting with Kim.

If Kim decides to offer few or virtually no substantive concessions on his nuclear program, Trump may be forced to accept that containment — letting North Korea keep its nukes and using deterrence to stop it — is his only option.

There is also the possibility that he is so upset by his inability to extract some kind of deal or victory from the situation that he decides to discard diplomacy altogether.

“I fear this could lead to a revival of the military talk ... that he would simply be so frustrated that he’d walk away — and turn toward military solutions,” Person said.

If that ends up being the case, Moon won’t just feel all his efforts were for naught. He may end up regretting them.