North Korean chief delegate Kim Song-Hye (L) shakes hands with her South Korean counterpart Chun Hae-Sung during talks on June 9, 2013. North and South Korea agreed early Monday after marathon talks to hold a government-level meeting in Seoul with the aim of rebuilding trust following months of tensions and threats of nuclear war

North and South Korea agreed early Monday after marathon talks to hold a government-level meeting in Seoul with the aim of rebuilding trust following months of tensions and threats of nuclear war.

Sunday's preparatory discussions -- weighed down, as always, by decades of mutual distrust -- were held in the border truce village of Panmunjom where the armistice ending the 1950-53 Korean War was signed.

After nearly 18 hours of negotiations, the two sides early Monday reached agreement on holding their first high-level talks since 2007, the South's Yonhap news agency reported.

The main challenge was to agree a framework for the talks to be held in Seoul on Wednesday and Thursday.

South Korea had called for a ministerial meeting but the talks are now described as a government meeting between the two sides.

The Unification Ministry in Seoul said the two sides had reached a partial understanding on outstanding issues during the Panmunjom talks, Yonhap said.

The North's official Korean Central News Agency meanwhile said the meeting would focus on restoring suspended commercial links, including the Kaesong joint industrial complex that the North effectively shut down in April as tensions between the historic rivals peaked.

It said other issues included reunion of families separated since the war and the resumption of tours by South Koreans to the North's Mount Kumgang resort. These were suspended after a North Korean soldier shot dead a South Korean tourist there in July 2008.

"It was agreed to discuss immediate and urgent matters concerning the inter-Korean relations including the issue of normalising the operation of the Kaesong industrial zone, the issue of resuming the tour of Mt. Kumgang, the issue of reunion of separated families and their relatives and other humanitarian issues," KCNA quoted a press release as saying after the talks ended.

Sunday's talks came about after an unexpected reversal from North Korea, which suddenly dropped its default tone of high-decibel belligerence and proposed opening a dialogue.

South Korea responded swiftly with its offer of a ministerial meeting in Seoul, the North countered with a request for lower-level talks first and -- after some relatively benign to-and-fro about the best venue -- Sunday's meet in Panmunjom was agreed.

In a further signal of intent, North Korea on Friday restored its official hotline with the South, which it had severed in March.

The move towards dialogue has been broadly welcomed -- given the threats of nuclear war that were being flung around in April and May -- but there is sizeable scepticism about Pyongyang's intentions.

"The North Korean offer has all of the hallmarks of Pyongyang's diplomacy," said Stephan Haggard, a North Korea expert at the Peterson Institute for International Economics.

"Pyongyang is 'sincerely' and 'magnanimously' inviting the South to fix, and pay for, problems of the North's own creation," Haggard said.

It was the North's decision to withdraw its 53,000 workers in early April that closed the Kaesong industrial estate.

Kaesong and Mount Kumgang were both significant sources of scarce foreign currency for North Korea, which is squeezed by UN sanctions imposed over its nuclear weapons programme.

There are also suggestions that Pyongyang was playing to a specific audience by proposing talks just before US President Barack Obama and Chinese President Xi Jinping sat down for their crucial summit in California.

China, the North's sole major ally and economic benefactor, has been under US pressure to restrain its neighbour and has pushed Pyongyang to drop its destabilising strategy of confrontation.

On Saturday, Obama and Xi closely consulted on North Korea's recent nuclear brinkmanship, and agreed to work together on the "denuclearisation" of the Korean peninsula, US National Security Advisor Tom Donilon said.

Analysts say South Korea will approach talks with Pyongyang with a caution born of long experience.

President Park Geun-Hye, who took office in February with a promise of greater engagement with Pyongyang, has welcomed the initiative.

But she remains adamant that any substantive dialogue can only take place if the North shows some tangible commitment to abandoning its nuclear weapons programme.

North Korea has been equally emphatic in declaring its nuclear deterrent is not up for negotiation.

It was the North's nuclear test in February -- and subsequent UN sanctions -- that triggered the recent crisis, which saw Pyongyang threaten both the South and the United States with pre-emptive nuclear strikes.