At least 29 soldiers have been killed in Niger in the deadliest attack since the army staged a coup in July.
The soldiers were killed by hundreds of jihadists using “improvised explosive devices and kamikaze vehicles”, the defence ministry said.
It added that “several dozen terrorists” were also killed in the counter-offensive that took place near the border with Mali.
Jihadist attacks on the army have risen since the military seized power.
The coup leaders said they had overthrown President Mohamed Bazoum government as the security situation was deteriorating.
France is withdrawing its 1,500 troops from Niger before the end of the year, following pressure from the junta.
The French forces have been fighting the insurgency in Niger that spilled over from Mali in 2015.
Last week, France’s ambassador left Niger after being blockaded in the French embassy for several weeks on the orders of the junta.
Niger’s military declared a three-day national mourning period, following Monday night’s attack in the western Tahoua region.
The army was carrying out operations aimed at “neutralising the threat” posed by al-Qaeda and the Islamic State (IS) group when troops came under attack, the ministry said in a statement.
“Communications from the terrorists, who were forced to withdraw, have been intercepted,” it added.
The attackers “benefited from outside expertise”, the ministry said, without giving further details.
The recent uptick in jihadist attacks in Niger has been linked to a security vacuum after soldiers were reportedly recalled to the capital, Niamey, to guard the coup leaders.
Last Thursday, hundreds of militants riding motorbikes killed 12 soldiers in south-western Niger.
At least 17 soldiers were killed last month in another attack near the border with Burkina Faso.
There have also been a surge in jihadist and rebel violence in neighbouring Mali following the departure of French troops, and a UN force winding down operations at the request of the junta.
Mali is now relying on the Russian mercenary group Wagner to fight the jihadists.
Last month, the military leaders of Mali, Burkina Faso and Niger signed a security pact pledging to help each other to fight the militants or any external aggression.