The largest rebel group in Sudan's Darfur region has agreed to sign a peace deal with the government.
The breakthrough came when SLM leader Minni Minnawi returned to the talks, following a late-night session.
However, two smaller groups rejected the deal, following last-minute efforts to secure their support. The government has also agreed to sign.
International negotiators say the deal is the best hope for peace in Darfur, where 2m people have fled their homes.
The BBC's Alex Last, who is at the talks in the Nigerian capital, Abuja, says a huge round of applause was heard shortly after Mr Minnawi returned to the talks.
"I accept the document with some reservations concerning the power sharing," Mr Minnawi said.
DARFUR DRAFT PEACE PLAN
Pro-government Janjaweed militia to be disarmed
Rebel fighters to be incorporated into army
One-off transfer of $300m to Darfur
$200m a year for the region thereafter
Compensation for those forced to flee their homes
Regional government, if approved in a vote
One of his officials told the Reuters news agency that the Sudanese Liberation Movement (SLM) wanted more seats in parliament but had agreed to the deal to end the suffering of the people in Darfur.
Meanwhile, United Nations High Commissioner for Human Rights Louise Arbour has accused Sudan's government of offering "broad immunity" to members of the security forces involved in the Darfur violence and trying to minimise the scale of the problems.
In Abuja, government spokesman Abdulrahman Zuma looked forward to the end of the fighting.
"The deal is peace - I think that the victory today is for Sudan," he said.
However, a signing ceremony was delayed for three hours, as mediators try to persuade Abdelwahid Muhamed El Nur, leader of the smaller SLM faction, to sign up to the deal.
Our correspondent says there are doubts as to whether the plan is workable, but the mediators are counting on the fact that they have managed to get the support of the largest rebel group.
Sam Ibok, head of the AU mediation team, said the government thought the plan envisaged too many rebel fighters being integrated into the army.
"They have great misgivings about the amendments and they say practical problems will arise in the implementation... but they don't want to give anybody grounds to continue the war," he said.
The Sudanese government has hinted that once the deal is signed, it may lift its objections to the UN taking over the peacekeeping mission in Darfur from the African Union.
About two million people have been displaced
The smallest rebel group, the Justice and Equality Movement (Jem), insisted that it wanted fundamental changes to the document.
The group's chief negotiator, Ahmed Tugod, reiterated the rebels' demands for the post of vice-president in the Khartoum government and for Darfur to have a greater share of national wealth.
"We decided not to sign it unless changes are made," he said.
The three-year-old Darfur conflict has claimed some 200,000 lives and displaced more than two million people.
The rebels took up arms in 2003, accusing the government of discriminating against the black African residents of Darfur.
Pro-government Arab militia then launched a campaign, described as "genocide" by the US.
The Sudan government denies backing the Janjaweed militias accused of the worst atrocities, such as mass killing, rape and looting.