Landmine blasts, loudspeakers blaring propaganda, an exchange of artillery fire and threats of more hostilities had put both sides on edge along the Demilitarized Zone, the world's most heavily fortified border.
But after marathon talks between high-level officials, the two bitter foes said in the early hours of Tuesday that they had found enough common ground to dial back the situation.
Pyongyang expressed regret over the serious injuries suffered by two South Korean soldiers in landmine blasts in the DMZ, and Seoul agreed to switch off the loudspeakers pumping propaganda broadcasts over the border Tuesday, both sides said.
Korea watchers expressed relief that the deal had defused the risk of confrontation for the time being after a period in which North Korea had doubled its artillery forces on the front lines and sent most of its submarines out from their bases.
The agreement "reduces the risk of a miscalculation with so many forces on the ground there and room for an error," said Philip Yun, executive director of the Ploughshares Fund, a group that advocates nuclear disarmament. "This is really good news over the short term."
Uncertainty over Kim's limits
But the sudden escalation of military tensions in a region where tens of thousands of U.S. troops are based was as a reminder of the opacity and unpredictability of North Korea under its young leader, Kim Jong Un
"We don't have a sense of what the edge of his envelope is -- and clearly North Korea's trying to push the edge of the envelope," Yun told CNN.
The North Korean troop movements last week were significant enough to prompt top American commanders to review the war plan for defending South Korea in case there was a sudden indication that North Korea was going to begin a war, U.S. officials told CNN
U.S. State Department spokesman John Kirby welcomed the agreement announced by the two Koreas.
"We support President Park's tireless efforts to improve inter-Korean relations, which support peace and stability on the Korean Peninsula," he said, referring to South Korean President Park Geun-hye.
North to lift 'semi-war state'
North Korea's expression of regret in the text of the deal appeared to have been enough to satisfy Park, who had demanded an apology for the landmine blasts.
It's unclear whether North Korean officials used stronger language behind closed doors.
Kim Kwan-jin, the South Korean national security chief who participated in the talks, said it was "very meaningful" that "the North apologized over the landmine incident and that they agreed on making efforts to prevent such incidents from reoccurring and easing tension."
Under the deal, North Korea will lift its "semi-war state" that it announced late last week as military tensions escalated.
The South Korean Defense Ministry said Tuesday it was continuing to closely watch North Korean military movements following the agreement.
The two sides also agreed to hold future meetings aimed at improving relations and to step up civilian exchanges, including a possible reunion in September of families separated by the division of the Korean Peninsula.
Bigger issues remain unaddressed
But the deal doesn't address the bigger issues on the Korean Peninsula, notably Pyongyang's advancing nuclear program.
"In the next 10 years, we have the threat of North Korea with a substantial nuclear arsenal -- if we don't figure out a way to deal with them -- and a leader we don't know a lot about," said Yun, who was part of U.S. teams that negotiated with North Korea under former President Bill Clinton.
Analysts say the recent tensions have followed a familiar pattern of previous North Korea crises.
"I think the North had planned this out very specifically, planting these mines," Yun said. "They knew there was going to be a response from the South, therefore they could ratchet up or deescalate as they wished."
North Korea hasn't publicly acknowledged laying the mines in the DMZ and had previously rejected the accusations from South Korea and the United States that it did so.
The South's response of resuming of loudspeaker broadcasts across the border -- which included news broadcasts and Korean pop music -- infuriated the thin-skinned regime in the North
. Seoul hadn't used the tactic in more than a decade.