Seven soldiers were killed in combat, while five others died in a road accident responding to the attack.
The defence minister said over 100 militants had been killed in a counter-offensive.Jihadist attacks on the army have risen since the military seized power in July.
The army said it had staged the coup so it could better fight the militants, some of which are linked to al-Qaeda and the Islamic State group.
The junta has ordered French troops stationed in the country to help fight the jihadists to leave – last week, French President Emmanuel Macron agreed to withdraw them.
The French ambassador left Niger earlier this week after living under a blockade ordered by the junta for several weeks in the embassy. Now back in Paris, Sylvain Itté told French TV that the aim was to “break me down”.
Reports say soldiers from across the country have been recalled to the capital, Niamey, to guard the coup leaders, leaving large areas vulnerable to militant attacks.
At least 17 soldiers were killed last month in another attack near the border with Burkina Faso. This was the deadliest known attack in the country since the coup.
Niger’s Defence Minister Salifou Mody said Thursday’s attack was carried out by “several hundred terrorists riding their motorcycles” on the town of Kandadji.
“A search and sweep operation is now underway in order to track down the enemy,” the minister said.
It is still not clear who was behind the attack.
Earlier this month, Niger agreed with neighbours Burkina Faso and Mali to establish a defence pact to support each other against any armed rebellion or external aggression.
The US has more than 1,000 troops in Niger although they have not been asked to leave.
The departure of foreign and UN troops in Mali has also been followed by an uptick of violence by both Islamist insurgents and rebel groups.
Source Nehandaradio