President Donald Trump has agreed to meet North Korean leader Kim Jong Un by May for direct talks about that country’s nuclear arms and long-range missile programs, according to a senior South Korean official. Such a meeting would be the first between an American president and a North Korean leader.

Trump “will accept the invitation to meet with Kim at a place and time to be determined. We look forward to the denuclearization of North Korea. In the meantime, all sanctions and maximum pressure must remain,” Press Secretary Sarah Huckabee Sanders said in a statement.

White House officials did not explain what Trump would offer Kim in return for disarming.

Kim personally invited Trump to the negotiating table during recent meetings with top South Korean officials, Chung Eui-yong, the South’s national security adviser, said during an extraordinary statement delivered Thursday evening outside the West Wing.

The North Korean leader said he intends to stop nuclear and missile tests while talks are ongoing, according to Chung, who added that Kim assured the South Korean delegation last week that he is “committed” to giving up his atomic arsenal.

The South Korean official came to the White House earlier Thursday to brief Trump, telling the U.S. commander in chief his country thanks him for his “leadership and his maximum pressure campaign” against Pyongyang. Trump’s actions, Chung said, have “brought us to this juncture.”

Trump accepted the invitation during his Thursday afternoon meeting with Chung. After the evening announcement, the president tweeted that “great progress was being made but sanctions will remain until an agreement is reached. Meeting being planned!”

Kim Jong Un talked about denuclearization with the South Korean Representatives, not just a freeze. Also, no missile testing by North Korea during this period of time. Great progress being made but sanctions will remain until an agreement is reached. Meeting being planned!

South Korean officials hand-delivered a message from Kim to Trump on Thursday afternoon, CNN reported.

House Foreign Affairs Chairman Ed Royce said in a statement that Kim’s “desire to talk shows sanctions the administration has implemented are starting to work.”

But the California Republican also issued this warning to the administration: “Remember, North Korean regimes have repeatedly used talks and empty promises to extract concessions and buy time. North Korea uses this to advance its nuclear and missile programs.”

Trump as recently as Saturday referred to Kim as “a madman” and has long derisively called him “Little Rocket Man.” The U.S. president has also threatened U.S. military action to disarm North Korea — even suggesting on several occasions he might use nuclear weapons if Kim did not give up his atomic arms and missiles.

After months of bluster and threats toward Pyongyang, Trump on Saturday announced his administration would hold talks with the Kim government about its nuclear arms and long-range missile programs.

His predecessor Barack Obama told Trump before he was sworn in that North Korea would be the most pressing global problem he would need solve during his term. Since then, Trump has threatened to attack the country — even at times suggesting he would unleash America’s atomic arsenal to take out the North’s. His sudden pivot toward talks is just the latest example of how the 45th president’s policy stances often change in a flash.

“They, by the way, called up a couple of days ago and said, ‘We would like to talk,’” Trump said of the Kim government Saturday night during remarks at the annual Gridiron Dinner. “And I said, ‘So would we, but you have to de-nuke, you have to de-nuke.’”

After some of his critics warned he might start a major Asian conflict — or even a nuclear one — Trump on Saturday night softened his brash tone on Pyongyang, saying “maybe positive things are happening.”

“I hope that’s true and I say that in all seriousness. I hope that’s true,” he said.

Watch: Trump’s Threat to North Korea in UN Address

The U.S. president long vowed he would never hold talks with Kim’s government over its nuclear and missile program. For instance, on Aug. 30, Trump tweeted this saber-rattling message: “Talking is not the answer!”

The U.S. has been talking to North Korea, and paying them extortion money, for 25 years. Talking is not the answer!

Earlier that month on Aug. 9, Trump issued an implicit warning to North Korea, tweeting that the U.S. nuclear arsenal is “far stronger and more powerful” than it has ever been.

The previous day, Trump warned that the United States would hit the North with “fire and fury” if Pyongyang repeated threats that it would strike American targets. He took to Twitter and appeared to signal he was prepared to use nuclear weapons against the country if conflict broke out.

On Aug. 9, talks were not on the table, with the president tweeting that his “first order” after taking office was to “renovate and modernize our nuclear arsenal.” He then added that it was “far stronger and more powerful than ever before.”

My first order as President was to renovate and modernize our nuclear arsenal. It is now far stronger and more powerful than ever before....

On Saturday night, Trump contended he would be fine negotiating with Kim.

“As far as the risk of dealing with a madman is concerned, that’s his problem, not mine,” the U.S. commander in chief said. “He must be a fine man.”

“Do you think he’s a fine man?” Trump asked.

An ABC News reporter caught Trump and Vice President Mike Pence alone in a West Wing hallway early Thursday evening. The president again showed how much value he places on how he is portrayed in the media, saying of the coming announcement: “It's almost beyond that. Hopefully, you will give me credit.”