The countries made the announcement after three days of intense talks aimed at pulling the rivals back from the brink of war.
During the talks at the border village of Panmunjom, North Korea also agreed to lift a "quasi-state of war" that it had declared last week, chief South Korean negotiator and presidential security adviser Kim Kwan-jin told a televised briefing.
Kim said the two Koreas have also agreed to resume reunions of families separated by war in September. He said the countries will hold talks to improve their ties soon in either Seoul or Pyongyang.
The North's Korean Central News Agency also released the same details.
The announcement came after the second round of negotiations the rivals began Saturday after events at their heavily guarded border pushed them toward a possible military confrontation.
Both sides had wanted a face-saving way to avoid an escalation that could lead to bloodshed, especially the North, which is outmatched militarily by Seoul and its ally, the United States.
The announcement came after South Korean President Park Geun-hye on Monday said that without a clear North Korean apology for the mine attack that maimed two soldiers, the anti-Pyongyang propaganda broadcasts that infuriate the North would continue.
Kim said the loudspeaker campaign, which began after the blast, would stop at noon Tuesday unless an "abnormal" event happens.
Pyongyang had denied involvement in the land mine explosions and rejected Seoul's report that Pyongyang launched an artillery barrage last week. It was not clear whether North Korea's expression of regret meant it was now admitting its involvement.
Even as the two countries held talks over the weekend, South Korea's military said North Korea continued to prepare for a fight, moving unusual numbers of troops and submarines to the border.
These were the highest-level talks between the two Koreas in a year. Just the fact that senior officials from countries that have spent recent days vowing to destroy each other were sitting together at a table in Panmunjom, the border enclave where the 1953 armistice ending fighting in the Korean War was agreed to, was something of a victory.
The length of the talks was not unusual. While the Koreas often have difficulty agreeing to talks, once they do, overlong sessions are often the rule. After decades of animosity and bloodshed, finding common ground is a challenge.
The decision to hold talks came hours ahead of a Saturday deadline set by North Korea for the South to dismantle the propaganda loudspeakers. North Korea had declared that its front-line troops were in full war readiness and prepared to go to battle if Seoul did not back down.
An official from Seoul's Defense Ministry said about 70 percent of the North's more than 70 submarines and undersea vehicles had left their bases and were undetectable by the South Korean military as of Saturday. The official, who refused to be named because of official rules, also said the North had doubled the strength of its front-line artillery forces since the start of the talks Saturday evening.
It was not known whether North Korea pulled back troops from the border after the agreement was announced.
The standoff started with the explosions of land mines on the southern side of the Demilitarized Zone between the Koreas that Seoul says were planted by North Korea. In response, the South resumed anti-Pyongyang propaganda broadcasts for the first time in 11 years, infuriating the North, which is extremely sensitive to any criticism of its authoritarian system.
Analysts said the North fears that the broadcasts could demoralize its front-line troops and inspire them to defect.
On Thursday, South Korea's military fired dozens of artillery rounds across the border in response to what Seoul said were North Korean artillery strikes meant to back up an earlier threat to attack the loudspeakers.
At the talkls, Kim and Unification Minister Hong Yong-pyo sat down with Hwang Pyong So, the top political officer for the Korean People's Army, and Kim Yang Gon, a senior North Korean official responsible for South Korean affairs. Hwang is considered by outside analysts to be North Korea's second most important official after supreme leader Kim Jong Un.
U.N. Secretary-General Ban Ki-moon quickly issued a statement welcoming the news of an agreement and stressing the importance of its full implementation.
"I strongly encourage humanitarian measures such as reunions of separated families to be regularized without being subject to political and security considerations," Ban said. "I further hope that this hard-won momentum for inter-Korean dialogue will lead to the resumption of talks for addressing the nuclear issue."