North and South Korea have ended four days of high-level military talks with agreement on cross-border train tests and the disputed western sea border.
The South wants to secure future border crossings
In a joint statement the two sides said they had agreed to provide security guarantees for a rail test-run across the border planned for next week.
They also agreed to create a joint fishing zone in the West Sea, the scene of bloody naval clashes in the past.
Analysts say the deal is a significant breakthrough for the two Koreas.
South Korea has long sought security guarantees from the North for a train to cross the heavily fortified border.
The test-run, scheduled for 17 May, will see the first such crossing since rail links between the two were severed during the 1950-53 Korean War.
Tracks have been reconnected - alongside roads - as part of recent reconciliation projects.
"The two sides have decided to discuss the issue of adopting a statement of agreement on military security for the operations of railways and roads," the joint statement said.
If the test goes ahead, a train will cross from the North on the east coast and another will cross from the South on the west coast, officials said.
They will travel about 25km (16 miles) and terminate their journeys a few kilometres inside the opposite territory.
However, the north has resisted demands to allow further crossings after that.
The talks by generals in the truce village of Panmunjom were extended into a fourth day so they could seek a resolution to the disputed maritime border, Yonhap news agency reported.
Pyongyang does not recognise the border drawn by the United Nations at the end of the Korean War, which has resulted in naval clashes over the rich fishing grounds.
Previous talks on cross-border trains have collapsed because of the North's insistence that the sea border issue be discussed.
"The two sides have shared the view that preventing military conflict and creating a joint fishing zone in the West Sea is an issue to be urgently resolved in the course of easing military tension and establishing peace," Friday's joint statement read.
This is the latest in a series of relationships that have slowly been re-established between the two sides in recent years, as the South has sought to engage with the secretive neighbour it is still technically at war with.
A rail link would bring advantages to both sides.
For South Korea, it would mean easily transporting goods produced using cheap North Korean labour. Seoul hopes one day to connect its rail network to the Trans-Siberian railway, which runs from China through to Europe.
The line would also boost tourism for the North, by providing a link for South Koreans to a mountain resort on the east coast.