The Nigerian army says it has rescued more than 5,000 people who were being held hostage by Boko Haram following a clearing operation in four remote villages in the northeastern Borno state.

"Our troops have decisively dealt with the Boko Haram terrorists, particularly hibernating in Sambisa forest, which used to be their stronghold," Colonel Sani Kukasheka Usman, army spokesman, told Al Jazeera on Sunday.

The soldiers evacuated the villages of Zangebe, Maiwa, Algaiti and Mainari, the army said in a statement .

The fighting led to the killing of one civilian and six Boko Haram fighters, it added.

The 5,000 rescued, mostly women and children, had been living under Boko Haram for more than six years, since the armed group launched its violent campaign in 2009.

The army also reported that two other Boko Haram fighters were killed in a separate mission to 11 villages in Borno.

Boko Haram pledged support for the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) last year.

The Nigeria-based group's armed campaign, which has spread into neighbouring countries, has killed more than 20,000 people and driven some 2.5 million from their homes.

READ MORE: Nigeria hosts summit on battling Boko Haram

Under President Muhammadu Buhari's command, and aided by Nigeria's neighbours, the army has recaptured most of the territory seized by Boko Haram - but the armed group still regularly stages attacks.

Last month, Nigeria hosted regional and Western powers to discuss ways to defeat the group.