The announcement comes on the eve of the West African country's general elections.
"Just this morning, the gallant troops of the Nigerian military in a concerted and well-coordinated land and air operations have liberated Gwoza, the headquarters of their so-called caliphate," Major General Chris Olukolade said in a Defense Ministry statement Friday.
Olukolade said the troops had routed Boko Haram fighters in towns and villages leading to Gwoza.
"Several of the terrorists have died and many of them captured in the process. A lot of arms and ammunition have been recovered and the administrative headquarters completely destroyed. A massive cordon and search has commenced to locate any of the fleeing terrorists or hostages in their custody," Olukolade said.
Boko Haram declared its own "caliphate"
after seizing the area around Gwoza, in Borno state, in August 2014, according to the Chatham House think tank
. The militant group has purportedly pledged allegiance to ISIS and says its aim is to impose a stricter enforcement of Sharia law across Nigeria, which is split between the majority Muslim north and the mostly Christian south.
Nigeria's general elections take place Saturday .
The polls had been scheduled for February 14, but on February 7, Nigeria's election commission
announced they would be postponed for six weeks due to security concerns, with the military needing more time to secure areas controlled by Boko Haram. The controversial decision was unpopular among many Nigerians
and led to widespread protests.
Nigerian President Goodluck Jonathan, who is running for reelection, has been criticized for not doing enough to combat Boko Haram.
On Friday, Jonathan referenced the Gwoza victory in a broadcast to the nation, praising Nigeria's armed forces for their "immense sacrifices" in defending the nation.
"We are also glad that our gallant armed forces have successfully stemmed the seizure of Nigerian territories in the northeast by the terrorist group, Boko Haram," Jonathan said. "They have recaptured most of the communities and territories formerly occupied by the insurgents, making it possible for thousands of internally displaced Nigerians to begin returning to their homes and communities."
Election peace pledge
Jonathan said security agencies were fully prepared to deal decisively with "any group or persons who attempt to disrupt the peaceful conduct of the elections."
"Those who may harbor any intentions of testing our will by unleashing violence during the elections in order to advance their political ambitions should think again as all necessary measures have been put in place to ensure that any persons who breach the peace or cause public disorder during or after the elections are speedily apprehended and summarily dealt with according to our laws," the President said.
On Thursday, Jonathan and Maj. Gen. Muhammad Buhari, the other leading presidential candidate, issued a pledge reaffirming their commitment to "free, fair and credible elections
" following their signing of a nonviolence pledge -- the Abuja Accord
-- in January.
The International Criminal Court also issued a warning that anyone inciting or engaging in electoral violence "at a time when abhorrent levels of violence already plague parts of the country" is subject to prosecution, "either by Nigerian Courts or by the ICC."
"No one should doubt my Office's resolve to prosecute individuals responsible for the commission of ICC crimes, whenever necessary," ICC Chief Prosecutor Fatou Bensouda said in the statement.
Boko Haram attacks have killed at least 1,000 civilians so far this year, according to a Human Rights Watch (HRW) statement released Thursday.
Citing interviews with witnesses, it said the militants rounded up 300 Gwoza residents when it overran the town, then took them to a camp in the Sambisa Forest.
"After five months during which other residents remained trapped on the hills, hiding in caves and weakened by hunger, Boko Haram attacked the civilians there, killing many and forcing others to escape over the border into Cameroon," the rights group said.
"Each week that passes we learn of more brutal Boko Haram abuses against civilians," said HRW researcher Mausi Segun, adding that Nigeria "needs to make protecting civilians a priority in military operations against Boko Haram."