Rival Sudanese forces have agreed to withdraw from the north-south border, ahead of the south's independence next week.
The deal agreed in Ethiopia comes after fighting in two border areas, Abyei and South Kordofan, which has forced some 170,000 people from their homes.
When the troops pull out, they are to leave a 20km (12-mile) buffer zone along the border.
The fighting had raised fears that the 21-year north-south war could resume.
This agreement, brokered by former South African President Thabo Mbeki, follows separate deals to end the fighting in Abyei and South Kordofan.
It is to be monitored by international observers and UN peacekeepers.
Abyei is claimed by both sides, while the fighting in South Kordofan pits northern forces against mostly ethnic Nubans who fought for the southern rebels during the civil war but now find themselves in the north.
The BBC's Peter Martell in the southern capital, Juba, says the agreement is not as easy to implement as it sounds, as parts of the border are still contested and it has not been demarcated.
He says the deal will come as a relief to many in Juba but people will be keen to make sure it is implemented.
On Tuesday, it was agreed that the former southern fighters in South Kordofan would either be integrated into the northern army or disarmed.
The agreement, mediated by the African Union, also covers the neighbouring Blue Nile state, which has many former southern fighters but which has been relatively peaceful.
The document stresses that any disarmament will be conducted without force.
Earlier this week, the UN Security Council endorsed the deployment of 4,200 Ethiopian troops to keep the peace in Abyei after a previous deal to make it a demilitarised zone.
The two sides are still to agree on how to divide Sudan's oil wealth after independence.
Some 75% of the oil fields lie in the south but the pipelines flow north to the Red Sea port of Port Sudan.
At present, the revenues are supposed to be shared equally.