Under the accord mediated by South Africa, Congo President Joseph Kabila will remain the interim head of state until the elections can be held in about 30 months.
The interim government will also include four vice presidents named from the government, the two rebel groups and the political opposition.
The deal was signed in the South African capital shortly after 2 a.m. Tuesday when negotiators approved a list assigning ministries to the various groups. That Ugandan-backed rebels agreed to give up the finance portfolio to the government in exchange for the presidency of the 500-member national assembly, delegates at the talks said.
Civil society representatives will chose the head of the 120-member senate, Joseph Mudumbi, foreign affairs chief of the Rwandan-backed Congolese Rally for Democracy, or RCD, said.
The talks were a continuation of earlier negotiations held at the South African resort of Sun City in which rebels and the government agreed to the basic structure of the power-sharing agreement. But the negotiations bogged down over control of the army, police, diplomats and public companies.
The agreement signed Tuesday calls for the deployment of a national police force drawn from government-and rebel-held areas to maintain law and order in the Congolese capital, Kinshasa, Mudumbi said.
A U.N. force is expected to be deployed in Kinshasa to guarantee the security of rebel leaders when they arrive to take up their new jobs, he said. Each rebel leader will take between five and 15 bodyguards with him, Mudumbi said.
On Dec. 4, the U.N. Security Council authorized the expansion of the United Nations Mission to Congo, or MONUC, from 5,537 to 8,700 international military personnel.
A committee is supposed to work out details of the deal, said RCD head Adolphe Onusumba, who is set to become one of the vice presidents. It was not clear how long it would take to implement the agreement.
"It might take some time before this agreement is applied on the ground, Onusumba said. "Since we negotiated for a political solution to the war, all it takes is commitment from all sides to make it work."
War broke out in Congo in August 1998 when Rwanda and Uganda backed Congolese rebels seeking to oust then-President Laurent Kabila. Angola, Zimbabwe and Namibia sent troops to support the government.
Rwanda and Uganda had backed Laurent Kabila in his successful effort to oust President Mobutu Sese Seko in 1997, when the country was called Zaire, but then broke with him over his failure to crack down on Hutu rebels sheltering in the eastern Congo.
Laurent Kabila was assassinated in early 2001, and his son took over.
An estimated 2.5 million people have died mainly from war-induced hunger and disease in the conflict in the resource-rich central African nation about the size of Western Europe.
The sale of precious minerals — like diamonds — abroad helped fund the bloody war, and revelations of this funding link led to a drive to track so-called "conflict diamonds" and prevent their sale.
The Congo war was one of several festering conflicts that gripped Africa in recent years, where war and AIDS have collaborated to reduce life expectancy across the continent, reversing years of progress. Fighting has also vexed Sierra Leone, Ivory Coast, Ethiopia and Eritrea, Morocco and Western Sahara, and Somalia.