The ambush took place on Tuesday about 60 km (40 miles) from the capital Niamey, in a southwestern area that borders Burkina Faso, the defense ministry said, adding that 100 attackers it referred to as "terrorists" were killed.
"The swift reaction of the soldiers and the air-land response at the scene of the skirmish enabled the enemy to be dealt with," the ministry said.
The Economic Community of West African States, the main regional bloc, said it had learned with sadness of various attacks by armed groups that had led to the death of "several" soldiers. It called on Niger's military leaders to restore constitutional order so they could focus on security, which it said had become increasingly fragile since the coup.
Niger, like other countries in West Africa's Sahel region, has been struggling for years to contain an insurgency by groups linked to al Qaeda and Islamic State that have killed thousands, forced millions to flee their homes and caused food shortages.
The perceived inability of civilian governments to overcome the problem has been one of the factors in a string of coups in the region, although in the case of Niger the main drivers of the army takeover were internal politics.
Members of the presidential guard, headed by Gen. Abdourahmane Tchiani, deposed President Mohamed Bazoum and are still detaining him, defying pressure from the United Nations, ECOWAS and Western powers to reinstate him.
While Tchiani said the takeover was necessary to quell the insurgency, analysts say attacks, though still frequent, had been falling under Bazoum, who had tried to engage with Islamists and rural communities where they are rooted.
Niger hosts U.S., French, German and Italian troops as part of international efforts to combat the insurgency, under agreements with the now deposed civilian government.
The future of those foreign contingents is unclear, with the junta using vitriolic anti-French rhetoric and resisting pressure from ECOWAS, the U.N. and Western countries to negotiate a way out of the current situation.
The United States said on Wednesday that the new U.S. ambassador to Niger would arrive in Niamey as a signal of Washington's continued engagement with the situation, although it declined to specify when.
Niger has extra strategic importance to global powers due to its uranium and oil deposits.
Insecurity remains a major problem across the southwest, near the border with Mali and Burkina Faso, both of which also have army governments that took control through coups.
On the Malian side, the departure of French troops last year left a security vacuum that the Islamists have exploited.
Mali's junta brought in mercenaries from Russia's Wagner group, who have been accused of executing civilians and committing other grave human rights abuses. Wagner says it works lawfully.
Niger's coup leaders have revoked a raft of military agreements with France, although Paris shrugged this off by saying that it did not recognize them as legitimate authorities.