"No more blood must run," Congolese President Joseph Kabila said before signing the agreement with Rwandan President Paul Kagame in a ceremony in South Africa.
The agreement, the latest in a string of efforts to end a war that has embroiled six African nations, commits Rwanda to pulling its 30,000 troops from Congo in exchange for Congo repatriating thousands of Rwandan rebels that have used the country as a base for attacks on Rwanda.
"There is a time for war. There is also a time for peace," Kabila said.
War broke out in Congo in August 1998 when Rwanda and Uganda backed Congolese rebels seeking to oust then-President Laurent Kabila, whom the two countries accused of supporting rebels who threatened their security. Angola, Zimbabwe and Namibia sent troops to support the government.
An estimated 2.5 million people have died in the conflict in the massive, resource-rich nation, mainly from war-induced hunger and disease.
South African President Thabo Mbeki and U.N. Secretary-General Kofi Annan brokered the agreement between Rwanda and Congo.
A key element of the deal is Congo's commitment to round up, disarm and repatriate the estimated 12,000 Rwandan Hutu militia fighters, who fled into Congo after taking part in the 1994 genocide in Rwanda that killed more than 500,000 people, mostly from the Tutsi minority.
Under the agreement, Congo is to begin rounding up the Hutu militia fighters 30 days after the deal is signed. Rwanda's withdrawal will begin 15 days later and is to be completed in 45 days. Both processes are to be monitored by a force whose composition has not yet been spelled out.
The agreement also requires Congo and Rwanda to provide the U.N. observer mission in Congo and South African officials with all information they have on the location and numbers of the Hutu militia.
Kagame called the agreement a "big step" in resolving the conflict "so that the Congolese people can be able to live in peace and struggle to build their country."
He also called on foreign nations to work with the two countries to help ensure the peace deal succeeds.
"If they come on board and support these efforts, we shall be able to move forward," he said. "Since some of them historically have been part of the problem, they cannot escape responsibility of being part of the solution."
In what appeared to be a confidence building measure, Congo, which had armed the Rwandan Hutu fighters, joined the United States on Monday in a $5 million "most-wanted" campaign searching for top fugitives in the Rwandan genocide. The nine suspects, indicted by an international tribunal, are believed to be at large in Congo.
Rwandan-backed Congolese rebels — whose estimated 40,000 troops control about 30 percent of Congo — will begin separate negotiations with the Congolese government on Aug. 5, according to rebel officials.
The talks will be aimed at forming a transitional government to prepare Congo for its first free and fair elections since independence from Belgium in 1960.