Nigeria's military recaptured the northeastern town of Rann on Tuesday after it was overrun by Islamic State West Africa (ISWA) insurgents a day earlier, weeks ahead of an election in which security has become a key campaign issue.
Nigerian government forces and residents fled during the ISWA attack as the militants set buildings ablaze, but troops fought back and regained control of Rann early on Tuesday, military and police sources said.
"Boko Haram invaded Rann at about 4pm (on Monday). The battle continued for about three hours. Our troops retreated and later returned to fight back," said a soldier speaking on condition of anonymity.
Nigeria President Muhammadu Buhari came to power in 2015 on promises to defeat the Boko Haram Islamist insurgency aimed at creating an Islamic state in the northeast.
ISWA, which split from Boko Haram in 2016, has launched a series of attacks in recent weeks, renewing debate about security in the run-up to elections on Feb. 16.
In December, ISWA took the town of Baga - the Nigerian headquarters of a multi-national force formed by Nigeria, Chad, Cameroon and Niger to fight the extremists - and more than 30,000 people fled.
The military launched a counter-offensive last week and retook the town, saying it had given ISWA a "bloody nose".