The M23 rebel group in the eastern Democratic Republic of Congo says it is ending its insurgency, hours after the government claimed military victory.
In a statement, the movement said it would adopt "purely political means" to achieve its goals and urged its fighters to disarm and demobilise.
The government said the last remaining rebels had either surrendered or fled across the border overnight.
Since the 19-month conflict began, some 800,000 people have fled their homes.
A summit of African leaders on Monday night in the South African capital Pretoria agreed that the M23 should make "a public declaration renouncing rebellion" to allow a peace accord to be signed with the Congolese government.
DR Congo government spokesman Lambert Mende told the BBC on Tuesday that Congolese special forces had driven the rebels out of the final hilltop strongholds. Tanks and helicopters from a UN intervention brigade had also been involved in recent fighting.
"We can say that it's finished. But you never know," Mr Mende said. "Those who escaped can come with hit-and-run operations so we have to end everything politically so that we are sure our people can sleep quietly without any threat."
Rebel military leader Sultani Makenga was among those who had crossed the border either to Rwanda or Uganda, he added.
Hours later, M23 leader Bertrand Bisimwa announced that "the chief of general staff and the commanders of all major units are requested to prepare troops for disarmament, demobilisation and reintegration on terms to be agreed with the government of Congo".
The Congolese army began a big offensive against rebel positions in late October, securing their last major stronghold at Bunagana on the Ugandan border last week.