The group said in a statement carried by its AMAQ news agency and posted on its Telegram channel that the soldiers were killed in an ambush on a convoy near the town of Teguey in the Tillaberi region in the west of the country.
Niger's defence ministry said late on Thursday that 23 soldiers were killed in the attack, which also wounded 17 more. Around 30 attackers were killed, it added.
Niger is one of several West African countries battling an Islamist insurgency that has spread outwards from Mali over the past 12 years, killing thousands and uprooting millions of people.
Frustrations over authorities' failure to protect civilians has spurred military coups in Mali, Burkina Faso and Niger since 2020.
The juntas that seized power have cut ties with Western allies assisting local military efforts, kicking out French and other European forces and turning to Russia instead. Niger's junta last week revoked with immediate effect a military accord that allows military personnel and civilian staff from the U.S. Department of Defense on its soil.