SEOUL, South Korea - In the biggest step toward peace since the end of the Korean War, the leaders of North and South Korea signed an agreement Wednesday pledging to work for reconciliation and eventual reunification.
The two leaders also agreed to allow reunions of families that have been separated for 50 years by the closed and heavily armed border, to hold another summit meeting and to promote South Korean investment that is desperately needed in the North's failing economy.
''Don't worry about anything. Have a good night's sleep and a safe trip home tomorrow,'' North Korean leader Kim Jong Il said to his counterpart, President Kim Dae-jung, after the two signed the accord following hours of talks in Pyongyang, North Korea's capital.
However, the agreement did not deal with two major strategic concerns: the North's demand that the United States withdraw its 37,000 troops from South Korea, and the North's nuclear and long-range missile programs that have led Washington to label it as a dangerous ''rogue'' state.
The United State wants to modify the 1972 Anti-Ballistic Missile treaty it signed with Moscow and develop a missile defense system to deal with the threat from countries like North Korea, a proposal Russia has warned would lead to a new nuclear arms race.
Reunification itself is an enormous task that some observers say could take decades, even if both countries honor the accord.
In the United States, the Clinton administration praised the agreement, saying it hopes the two Koreas can uphold it and benefit from it. ''It's certainly our hope that they can find some way to build on the success of the last two days,'' said White House press secretary Joe Lockhart in Washington.
Lee Hong Koo, South Korea's ambassador to Washington, said American troops in South Korea will remain there for the indefinite future. Asked in an interview whether the summit will lead to a U.S. troop withdrawal, Lee said, ''That's a long way off.''
The agreement signed in Pyongyang is more detailed than similar ones that were reached by lower-ranking officials in 1972 and 1991. Those deals, which also called for reconciliation and reunification, quickly gave way to renewed hostilities.
South Koreans were surprised by the warmth and openness displayed by the North's leader, Kim Jong Il, the reclusive leader who rules by decree and who has been widely condemned for human rights abuses in his country.
From the moment he warmly met his counterpart, South Korean President Kim Dae-jung, at the airport in Pyongyang on Tuesday, the North Korean leader seemed prepared to reach out to the West and its successful, free-market economies.
After the late-night signing, the two leaders smiled broadly, shook each others' hands vigorously and toasted each other with glasses of champagne.
Kim Dae-jung praised Kim Jong Il for helping him reach a ''historic agreement'' and said the two must ''proceed together on a path of reconciliation and cooperation.''
In Seoul, many South Koreans also welcomed the accord.
''I have never thought seriously about reunification with North Korea. For me, that has always been an abstract and remote issue. Now it suddenly looms as a very realistic dream,'' said 27-year-old Paek Hong-ki.
But others were cautious about whether North Korea would comply with the agreement.
''The agreements look very superficial,'' said Kim Sun-ja, 47. ''We will have to wait and see if this reunion of separated families actually takes place.''
The summit was covered by about 50 South Korean reporters who traveled to Pyongyang and were filing print and television pool reports to the hundreds of foreign reporters who had to remain behind in Seoul, 120 miles to the south.
The agreement said the cross-border visits would occur this summer and involve an unspecified number of the tens of thousands of families that have lived on opposite sides of the Demilitarized Zone for decades. The last such exchange occurred in 1985 and involved only 50 people from each side.
South Korea also agreed to repatriate an unspecified number of convicted North Korean spies who have completed their jail terms in the South.
The accord said the next inter-Korean summit would be held in Seoul, the South Korean capital, but no date was set. Such a visit would indicate Kim Jong Il's sincerity in pursuing reconciliation because it would expose him to the kind of press coverage and potential protests that he never faces at home.
As the leaders' three-hour meeting began in Pyongyang on Wednesday, Kim Jong Il surprised the world by starting it with lighthearted comments.
Wearing his gray Mao-style jacket and sitting opposite Kim Dae-jung at a conference table, Kim Jong Il praised his counterpart for making the brave decision to travel to North Korea for the first time ever on Tuesday for the three-day summit.
In talks that Kim Dae-jung held earlier Wednesday with other top North Korean officials, they discussed opening highway and railway lines across the two countries' border for the first time in more than 50 years, holding a second summit in Seoul, and creating a ''hot line'' telephone service for discussions during crises. But no agreements were reported on this.
The peninsula's rail and road lines were closed around 1948, when the two Koreas formed their own governments and sealed their border. The 1950-53 Korean War ended in a draw - no peace treaty was even signed - and troops remain massed on both sides of the Demilitarized Zone.
Kim Dae-jung was scheduled to fly home late Thursday.