The statement said seven soldiers died in combat while five others were killed in an accident while driving to reinforce the unit that was attacked.
The attack took place in Kandaji, about 190 km from the capital Niamey, near the tri-border region of Mali, Burkina Faso and Niger, which has been a hub for extremists in the Sahel region for the past few years.
Earlier on Thursday, three sources, including a senior army officer who asked not to be named because he was not authorized to speak to the media, told Reuters that at least ten soldiers had been killed.
Neither the sources nor the Ministry of Defense said who was responsible for the attack, but groups in the area affiliated with al-Qaeda and ISIS are active in the area and carry out repeated attacks on soldiers and civilians.
The defence ministry statement said about 100 rebels were killed and their motorcycles and weapons destroyed, without providing further details.
Two security sources said the army responded to the attack with ground troops and helicopters, one of which was hit but managed to return to its base.
Niger is run by a military council that seized power in a coup in July, partly out of discontent over the deteriorating security situation, but security analysts say attacks have been on the back of the era of ousted President Mohamed Bazoum.