North Korean leader Kim Jong-un and South Korean President Moon Jae-in embraced after pledging to work for the "complete denuclearisation of the Korean peninsula."
The pledge punctuated a day of smiles and handshakes at the first inter-Korean summit in more than a decade.
The two Koreas announced they would work with the United States and China this year to declare an official end to the 1950s Korean war and seek an agreement to establish "permanent" and "solid" peace in its place.
The declaration included promises to pursue phased military arms reduction, cease hostile acts, transform their fortified border into a peace zone, and seek multilateral talks with other countries including the United States.
"The two leaders declare before our people of 80 million and the entire world there will be no more war on the Korean peninsula and a new age of peace has begun," the declaration said.
Earlier, Mr Kim became the first North Korean leader since the 1950-53 Korean War to set foot in South Korea after shaking hands with his counterpart over a concrete curb marking the border in the heavily fortified demilitarised zone between the countries.
Scenes of Mr Moon and Mr Kim joking and walking together marked a striking contrast to last year's barrage of North Korean missile tests and its largest ever nuclear test that led to sweeping international sanctions and fears of a fresh conflict on the Korean peninsula.
Their dramatic meeting comes weeks before Mr Kim is due to meet US President Donald Trump in what would be the first ever meeting between sitting leaders of the two countries.
Mr Moon agreed to visit Pyongyang later this year, according to the declaration.
As part of efforts to reduce tensions, the two sides agreed to open a liaison office, stop propaganda broadcasts and leaflet drops along the border, and allow Korean families divided by the border to meet.
Just days before the summit, Mr Kim said North Korea would suspend nuclear and long-range missile tests and dismantle its only known nuclear test site.
But there was widespread scepticism about whether Mr Kim is ready to abandon the nuclear arsenal his country has defended and developed for decades as what it says is a necessary deterrent against US invasion.
It is not the first time leaders of North and South Korea have declared their hope for peace, and two earlier summits, in Pyongyang in 2000 and 2007, failed to halt the North's weapons programmes or improve relations in a lasting way.
"We will make efforts to create good results by communicating closely, in order to make sure our agreement signed today before the entire world, will not end as just a beginning like previous agreements before today," Mr Kim said after the agreement was signed.
Earlier, Mr Moon greeted Mr Kim at the military demarcation line where the men smiled and shook hands.
In an unplanned move, Kim invited Moon to step brieflyacross into North Korea, before the two leaders crossed back into South Korea holding hands.
"I was excited to meet at this historic place and it is really moving that you came all the way to the demarcation line to greet me in person," Mr Kim said.
"A new history starts now. An age of peace, from the starting point of history," Mr Kim wrote in Korean in a guest book in the South's Peace House before talks began.
Minutes before Mr Kim entered Peace House, a North Korean security team conducted a sweep for explosives and listening devices, and sprayed what appeared to be disinfectant in the air, on the chairs, and on the guest book.
The two leaders released their joint declaration before attending a dinner hosted by Mr Moon.
During a private meeting in the morning, Mr Kim told Mr Moon he came to the summit to end the history of conflict and joked he was sorry for waking Mr Moon up with his early morning missile tests, the official said.
Impoverished North Korea and the rich, democratic South are technically still at war because the Korean War ended in a truce, not a peace treaty.
The United States stations 28,500 troops in South Korea as a legacy of the Cold War conflict, which pitted the South, the United States and United Nations forces against the communist North, backed by China and Russia.
Mr Kim and Mr Trump are expected to meet in late May or June, with Mr Trump saying he was considering several possible dates and venues.
The latest Korean summit has particular significance not least because of its venue: the Demilitarised Zone, a 260km long, 4km wide strip of land created in the 1953 armistice to serve as a buffer between the South and North.