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.
US withdrawal from Niger could pose significant obstacles to counter-terrorism efforts in the Sahel region with repercussions for the entire continent.
The Sahel is witnessing a new era where Western powers lack substantial influence.
China and Russia are both broadening their economic and military footholds in Africa.
A variety of factors are leading to the decline of American influence in Africa and on a global scale.