In this Aug. 22, 2015 file photo provided by the South Korean Unification Ministry, South Korean National Security Director, Kim Kwan-jin, right, and Unification Minister Hong Yong-pyo, second from right, shake hands with Hwang Pyong So, left, North Korea' top political officer for the Korean People's Army, and Kim Yang Gon, a senior North Korean official responsible for South Korean affairs, during their meeting at the border village of Panmunjom in Paju, South Korea. (Photo:AP)
North and South Korea wrapped up marathon talks Tuesday with an agreement on a series of measures to defuse a crisis that had pushed the two rivals to the brink of armed conflict.
The measures detailed in a joint statement included what amounted to an extremely rare public apology from North Korea, which "expressed regret" over mine blasts this month that maimed two South Korean soldiers on border patrol.
In response, the South agreed to halt loudspeaker propaganda broadcasts into North Korea which it had resumed -- after a break of more than a decade -- in retaliation for the mine blasts.
The loudspeakers will be switched off midday (0300 GMT) Tuesday, at which time the North will lift a "semi-war state" declared last week by leader Kim Jong-Un.
The two also agreed to work towards a resumption next month of reunions for families separated by the 1950-53 Korean War, and to hold official talks in either Seoul or Pyongyang at a date to be decided.
The agreement, which appeared to cover all the major areas of contention, came after days and nights of gruelling negotiations which began early Saturday evening in the border truce village of Panmunjom.
The talks had played out against a dangerous military stand-off, which triggered a rare artillery exchange over the border last week, with both sides ramping up the military rhetoric and flexing their weaponry.
Tensions continued to rise as the discussions were taking place, with South Korean and US jets flying simulated bombing runs, and North Korea reportedly deploying two thirds of its 70-vessel submarine fleet.
"I hope that from now on, (both sides) sincerely implement the agreement and build trust through dialogue and cooperation in order to build new inter-Korean ties that meet the people's expectations," South Korea's lead negotiator, National Security Adviser Kim Kwan-Jin, told reporters.
Kim said the agreed measures would not only settle the current crisis, but also provide a "new momentum" for inter-Korean relations in the future.
The Panmunjom talks between Kim and his North Korean counterpart Hwang Pyong-So -- a close confidant of leader Kim Jong-Un -- were the highest-level inter-Korean talks for nearly a year.
There was some surprise at the unequivocal nature of the North Korean expression of regret over the mine blasts -- which many had predicted would be the main stumbling block to any agreement.
North Korea had repeatedly denied any responsibility for the blasts, and apologies for anything -- especially where South Korea is concerned -- are not in its usual diplomatic vocabulary.
"Past inter-Korea agreements at a time like this have tended to be extremely ambiguous," said Jeung Young-Tae, an analyst at the Korea Institute for National Unification in Seoul.
"But in the world of diplomatic language, this is a clear apology, with the object of the regret -- the landmine blasts that maimed the soldiers -- clearly stated," Jeung said.
On Monday, South Korean President Park Geun-Hye had insisted that Seoul would only switch off the propaganda loudspeakers if the North provided a "clear apology" for the landmine incident.
In televised remarks to a meeting of senior aides, a combative Park had also vowed "no retreat" in the face of North Korean provocation.
Tuesday's agreement noted that the South's undertaking to turn off the propaganda loudspeakers would be null and void if "an abnormal case occurs" -- an apparent reference to future provocations.
The agreement will be welcomed by neighbouring countries like China and Japan, which had viewed the stand-off on the Korean peninsula with growing concern and urged both sides to show calm and restraint.
It will also be viewed with some relief by the United States, which has nearly 30,000 US troops permanently stationed in South Korea and had repeatedly reiterated its commitment to the defence of its key Asian ally.
Technically, the two Koreas have been at war for the past 65 years since the 1950-53 Korean War ended with a ceasefire that was never ratified by a formal peace treaty.