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.
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.
BBC Africa security correspondent Tomi Oladipo says Gwoza's capture is a major milestone for the Nigerian army.
The town is not far from Chibok, where Boko Haram kidnapped more than 200 schoolgirls from a boarding school last April.
Our reporter says Gwoza was one of the places where the militants were rumoured to be hiding the girls, who are yet to be found.
After his fighters captured Gwoza in August 2014, the Boko Haram leader declared a caliphate in areas under his control.
The militants have been pushed back since Nigeria's neighbours, Cameroon, Chad and Niger sent troops to help it earlier this year.
"These successful operations have culminated in the dislodgment of terrorists from towns and communities in Adamawa, Yobe and Borno states," military spokesman Chris Olukolade said.
A lot of arms and ammunition were recovered and "a massive cordon and search has commenced to locate any of the fleeing terrorists or hostages in their custody", he said.
- Founded in 2002, initially focused on opposing Western-style education
- Boko Haram means "Western education is forbidden" in the Hausa language
- Launched military operations in 2009 to create an Islamic state
- Thousands killed, mostly in north-eastern Nigeria
- Has also attacked police and UN headquarters in capital, Abuja
- Abducted hundreds, including at least 200 schoolgirls
- Pledged allegiance to Islamic State
Maj-Gen Olukolade also thanked Nigeria's regional partners for their encouragement during the recent operations.
But Chad's President Idriss Deby has been fiercely critical of Nigeria's response, saying the Nigerian military had been uncooperative.
He told French magazine Le Point that Chadian troops have had to retake towns twice from Boko Haram because Nigeria's forces had failed to secure them.
He estimated Boko Haram had 20,000 young fighters, some of whom had been trained by Islamic State in Libya, the AFP news agency reports.