The Nigerian army says it has retaken the north-eastern town of Gwoza, believed to be the headquarters of militant Islamist group Boko Haram.
The insurgents had now been driven from virtually all the territory they had held, it said.
Some militants were now fleeing towards border areas, the military said.
News of Gwoza's recapture comes a day before presidential elections, which were postponed by six weeks because of the offensive against Boko Haram.
Meanwhile, the president of Chad, which is helping Nigeria fight Boko Haram, has strongly criticised Nigeria's military.
Thousands of people have been killed since 2009, when the group began its insurgency to create an Islamic state.
An estimated three million people have fled their homes because of the unrest, and many may be unable to vote.
Analysis: BBC's Will Ross, Lagos
Gwoza's location made an ideal base: The nearby Mandara Mountains offered protection and the jihadists could flee into Cameroon until the military there stepped up patrols. There is a complex system of caves and tunnels, some of which burrow hundreds of metres into the mountainside. Recent rumours suggest the Boko Haram leader may have been hiding there.
When Gwoza was captured by the jihadists last August thousands of residents were trapped and terrified on the mountain slopes with no food. They were badly let down - the military fled, leaving the jihadists to help themselves to the armoury.
Now on the eve of a pivotal election there is at last some good news for those who survived. The cost was high though.
One resident told me the jihadists recently assembled all the elderly residents and informed them that, as they were unable to defend themselves from a military attack, they would be helped on their way to paradise. They were slaughtered in Gwoza's abattoir.
Eyewitnesses say that after the military assault, people could be seen heading over the mountain by torchlight - Boko Haram fighters on the run.