US President Donald Trump has accepted an invitation to meet North Korea's Kim Jong-un, following months of diplomatic standoff that saw the two leaders exchange fiery military threats and personal insults.

The meeting would be a first between a sitting US president and a North Korean leader, offering a potential breakthrough in relations between the two adversaries.

Chung Eui-yong, South Korea's national security adviser, first made the announcement at the White House on Thursday evening, later confirmed by Trump in a social media post.

"President Trump appreciated the briefing and said he would meet Kim Jong-un by May to achieve permanent denuclearisation," Chung told reporters.

He said that the North Korean leader has expressed his "commitment to denuclearisation" and will "refrain from any further nuclear or missile tests" during the negotiations.

In a post on Twitter early on Friday, Trump wrote, "Meeting being planned!"

"Kim Jong-un talked about denuclearisation 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," Trump said.

In a briefing with reporters, Sarah Sanders, Trump's spokeswoman, said the US president "will accept the invitation to meet with Kim Jong-un at a place and time to be determined".

She added that "in the meantime, all sanctions and maximum pressure must remain".

The surprise announcement in Washington, DC, following an announcement by Chung on Tuesday that the North Korean leader had agreed to meet South Korea's President Moon Jae-in in April.

In a statement published in the South Korean news agency Yonhap, Moon declared, "The denuclearisation and peace of the Korean Peninsula is becoming a reality".

The agreements, which follow a flurry of cooperative steps taken by the Koreas during last month's Pyeongchang Winter Olympics, brightened prospects for a dialogue between North Korea and the US over the North Korea's nuclear programme.

Moon praised the Winter Games for setting the stage for a detente between the rival Koreas, adding that he hopes it will "create a new world peace".

'Maximum pressure policy'

On Thursday, Chung praised Trump's "leadership and his maximum pressure policy" for paving the agreement with North Korea.

In 2017, the UN Security Council had also unanimously adopted sanctions against Pyongyang following a series of intercontinental ballistic missiles tests and a nuclear test.

In February, Trump also announced the United States' "heaviest ever" sanctions against North Korea to prevent it from further developing its nuclear programme.

At the same time, however, the US leader said he is "absolutely" willing to talk to Kim Jong-un without conditions.

He also took credit for the recent rapprochement between the rival Koreas, as well as the US, saying that without his "rhetoric and tough stance ... they wouldn't be talking".

Trump and Kim have repeatedly traded barbs in the past. Trump has called Kim "rocket man", while Kim described Trump as a "dotard".

In January, Trump responded furiously to Kim's taunt of a nuclear button, by saying his button was "bigger and more powerful".

In South Korea, the news of the impending Trump meeting with Kim was greeted with "a real sense of excitement", according to Al Jazeera's Rob McBride, who is reporting from Pyeongchang.

Our correspondent said that the agreement was seen as a "success" for South Korean President Moon and his diplomatic effort.

"Given the intractability of the North Korean crisis, given the kind of vitriolic rhetoric even a couple of months ago, who knows what a handshake and a smile might do."

In Beijing, Pyongyang's closest ally, officials are taken by surprise by the news, although Chinese officials have been urging the two parties to talk, said Al Jazeera's Adrian Brown.

He said that if Beijing believes that if the Trump-Kim summit takes place, it will be hosted by China.