By DALATOU MAMANE, Associated Press

NIAMEY, Niger (AP) — Soldiers fended off an attack on a border town in Niger by Boko Haram and destroyed a base used by the Islamic militants inside neighboring Nigeria in recent days, Niger said Tuesday.

The two confrontations came as Nigeria elected a former military dictator as its new president amid anger over the Islamic insurgency that has claimed thousands of lives. The militants have terrorized northern Nigeria and also attacked towns in neighboring countries, prompting nations in the region to mount a force to combat them.

The militants tried to attack the town of Bosso, Niger, just over the border with Nigeria, on Monday, according to a statement from Niger's Defense Ministry. But troops from Niger and Chad — who are part of the force helping Nigeria to root out the insurgents — intervened, killing 47 militants and destroying several of their vehicles and mortars. The troops also captured a cache of weapons and ammunition.

On Saturday, troops from Niger and Chad destroyed a Boko Haram base inside Nigeria, also close to the Niger border, killing 54 militants, the statement said. Three troops from Niger were wounded in the raid, near the town of Talagam.

In the past two months, Nigeria's military, with the help of the regional force, has retaken dozens of towns from Boko Haram. At least 10,000 people were killed in the uprising last year and more than 1.5 million people have been driven from their homes.