The government of Congo reached a peace agreement today with its military and political opponents in an attempt to end a four-year civil war that has killed an estimated 2 million people in one of Africa's most volatile regions.

The accord, signed early this morning at a conference in the South African city of Pretoria, prescribes a power-sharing arrangement that would allow Congo's president, Joseph Kabila, to remain in office for at least two years, until democratic elections can be held. Four vice presidents would be appointed, one each from Kabila's government, the political opposition and two armed rebel groups -- the Rwandan-backed Rally for Congolese Democracy and the Ugandan-backed Congolese Liberation Movement.

Congo has been embroiled in the conflict commonly known as Africa's first world war since August 1998, when the rebels and their foreign backers launched an armed campaign aimed at toppling Kabila's father and predecessor, Laurent Kabila. After Angola, Zimbabwe and Namibia entered the fight on Kabila's side, the war settled into a stalemate that has left Congo divided roughly in half, with the rebels controlling the east and north and the government holding the south and west.

Under a peace plan reached in April 1999, foreign troops have withdrawn from Congo during the past year. But continuing distrust between the government and the rebels -- and between the rebel factions -- will pose major challenges to the new accord, observers said today.

In northern and northeastern Congo, the Ugandan-backed rebel faction is still fighting sporadically with a splinter group of the Rwandan-supported force. At the same time, fighting over land between the Hema and Lendu ethnic groups has claimed hundreds of lives in an area of the northeast left lawless by the war.

"It's a very important and good step, but the negotiation is not over. It's far from it when you look at the reality on the ground in the Congo," said Francois Grignon, the Central Africa project director for the Brussels-based International Crisis Group, an independent research and advocacy organization. "There's still fighting going on, and an entirely new social contract needs to take place for the Congo. There will have to be ongoing talks with local rebel groups and a deal that brings every last group together. That is the reality of seeing real peace in the Congo."

Congolese leaders said they were hopeful that the peace agreement would last.

"This is our Christmas present," said Michel On'Okono, an official at the Congolese Embassy in Nairobi, where Congolese refugees gathered and cheered when the news was announced. "We are not saying things are perfect, and it will be rough at times. But this is major progress and there are a lot of people who want to make it work."

President Thabo Mbeki of South Africa, whose government brokered the agreement, said bringing peace to one of Africa's prominent trouble spots is symbolically important to a continent where low-level civil wars continue in several countries. "The agreement has enormous regional implications," Mbeki told reporters in South Africa. "You couldn't genuinely say you were moving ahead in Africa if the situation in [Congo] remained unchanged."

Since gaining independence in 1960, Congo has been wracked not only by internal rebellion but by neighbors' conflicts -- notably in 1994, when thousands of Hutu extremists from Rwanda fled into Congo, then known as Zaire, after they participated in the slaughter of a half-million of Rwanda's Tutsi minority. Partly in reaction, Rwanda sponsored the 1998 Congo rebellion, as well as one in 1996 that ousted Mobutu Sese Seko and brought Laurent Kabila to power. Kabila was assassinated in 2001 and his son was installed as his replacement.

President Thabo Mbeki of South Africa, whose government mediated the Congo peace agreement, said it has "enormous regional implications."