Military reinforcements later arrived and stopped them as they tried to return to Mali, setting off a gun battle. The attackers escaped into Mali and were being pursued, the security official said.
A statement from Niger’s military, confirming the death toll, said: “Land and air forces are pursuing the assailants with a view to neutralizing them.”
Since taking over swaths of northern Mali in 2012, and then being scattered by a French-led counteroffensive the following year, Islamist militants have established themselves in lawless spaces across the desert.
They have used these areas as a springboard for a wave of attacks that threaten to destabilize West Africa. Fighters have inflicted damage on military outposts, killed security officials and civilians, kidnapped Westerners and sometimes mounted high-profile attacks on hotels and resorts across the region, including in Burkina Faso and Ivory Coast.
Several Islamist groups and well-armed ethnic militia operate in the area along the Mali-Niger border. There have been at least 46 attacks there since early last year.
However, officials suspect that many of the attacks, including the ambush this month on the joint United States-Niger patrol, are the work of the Islamic State in the Greater Sahara, led by the Arabic-speaking North African militant Adnan Abu Walid al-Sahrawi.
He has pledged allegiance to Islamic State militants in Iraq and Syria, although the extent of their ties are not known.
No group has yet claimed responsibility for the attack on Saturday, or for the ambush of the Americans.
Responding to its ever growing militant threat, Mali on Saturday announced a year extension of a state of emergency.
“I hope we won’t need to continue extending the state of emergency,” Defense Minister Tiena Coulibaly said. “We hope that before Oct. 31, 2018, order will be restored.”
The increasingly fluid, cross-border nature of the militant threat led Mali, Niger, Chad, Mauritania and Burkina Faso to establish — known as G5 Sahel — in July, to coordinate policing their deserts.
But it has yet to receive a commitment to more than a fraction of the donor funding that it needs. A United Nations Security Council delegation was in Mali on Saturday to discuss the force.