Media playback is unsupported on your device Media caption North and South Korea had a warm meeting in the DMZ

North and South Korea have agreed to hold military talks to defuse border tension, after their first high-level meeting in two years.

The North will also send a delegation to the 2018 Winter Olympic Games taking place in South Korea in February.

Agreement was also reached to reinstate a military hotline suspended two years ago, the South's government said.

However, the North's delegation was negative on the subject of denuclearisation, the South added.

The United States gave a cautious welcome to the meeting.

The state department said the US remained in close consultations with South Korean officials who would ensure the North's participation in the Winter Olympics did not violate UN sanctions.

What happened at the talks?

After a day of negotiations, the two sides issued a joint statement which confirmed they had agreed to hold military talks on defusing military tension.

The North also agreed to send a National Olympic Committee delegation, athletes, cheerleaders, art performers, spectators, a taekwondo demonstration team and media to the games, while the South would provide the necessary amenities and facilities.

The statement also referred to exchanges in other, unspecified areas and other high-level talks to improve relations, the South's Yonhap news agency reports.

Image copyright Getty Images Image caption North Korea first expressed interest in joining the Pyeonchang Games during the New Year

The South asked the North to end any hostile acts that might raise tension, while the North agreed there was a need to guarantee a peaceful environment on the peninsula, a statement from the South's government said.

Other details had been released throughout the day by officials from the South:

The South proposed that athletes from both Koreas march together at the opening ceremony in Pyeongchang as they did at the 2006 Winter Olympics

The South pushed for the reunion of family members separated by the Korean War - a highly emotional issue for both countries - to take place during the Lunar New Year holiday, which falls in the middle of the Games

The South said it would consider temporarily lifting relevant sanctions, in co-ordination with the UN, to facilitate the North's participation in the Olympics

The North's reaction to these proposals is not known.

In his opening remarks, the head of the North Korean delegation, Ri Son-gwon, was fairly neutral. He said he hoped the talks would bring a "good gift" for the new year and that the North had a "serious and sincere stance".

Where are the talks and how did they come about?

They were held in the Panmunjom "peace village" in the demilitarised zone (DMZ) at the border.

Five senior officials on each side attended and the leaders of both were said to have watched the talks via a CCTV feed.

Media playback is unsupported on your device Media caption Tensions are high between the two warring countries

In his New Year address, North Korean leader Kim Jong-un had said he was considering sending a team to the Olympics. South Korea's Olympics chief had said last year that the North's athletes would be welcome.

Following Mr Kim's overture, the South then proposed high-level talks to discuss the North's participation, but the North only agreed to the talks after the US and South Korea agreed to delay their joint military exercises until after the Olympics. The North sees the annual drills as a rehearsal for war.

Some critics in the US see the North's move as an attempt to divide the US-South Korea alliance.

Dramatic change

Analysis: BBC's Rupert Wingfield-Hayes in Seoul

A little over a week ago North Korea was threatening nuclear war - this morning a delegation from Pyongyang strode across the demarcation line that divides North and South Korea and agreed a North Korean delegation would attend the Pyeongchang Games.

It is a sudden and dramatic change after months of tension but few in the South believe any of this demonstrates a fundamental shift in Pyongyang's position.

Experts say North Korea's leader Kim Jong-un has become increasingly fearful that the US is planning a military strike against him, and has decided he must do something to de-escalate tensions.

South Korea's President Moon Jae-in has been put in the delicate position of trying to engage the North in genuine dialogue, while not upsetting his very sceptical American ally.

When were the last talks?

Back in 2015.

Relations then broke down after Seoul suspended a joint economic project at the Kaesong Industrial complex in North Korea following a rocket launch and nuclear test by the North.

The incident led to North Korea ending all communication with Seoul, including cutting off the military hotline.

Media playback is unsupported on your device Media caption Life in a South Korean border town

Tensions have risen in the years since.

How bad have things become?

The North's development of its nuclear programme has continued unabated and has created a huge diplomatic conflict with the US administration of President Donald Trump.

Mr Trump and Kim Jong-un have conducted a personal feud, with the US leader dubbing Mr Kim "Rocket Man" and boasting that his nuclear button is "much bigger".

North Korea's regular missile tests have brought a tightening of UN and US sanctions.

The latest test of a ballistic missile on 28 November sparked another raft of measures from the UN, targeting petrol shipments and travel for North Koreans, among other things.