MAIDUGURI, Nigeria (Reuters) - Islamist insurgents killed at least 25 soldiers and a number of civilians in an ambush in northeast Nigeria on Saturday morning, two security sources said, the second deadly attack on the army this week.

Militants opened fire as the soldiers were escorting a groups of evacuees from a village in Borno state, where Boko Haram and other militants have been fighting for a decade.

“They ambushed and surrounded the vehicles of both the soldiers and the civilians and opened fire on them,” said one of the sources, part of a vigilante group that fights alongside the military against the insurgencies.

“They exchanged fire for some minutes before the Boko Haram militants overpowered the soldiers.”

Nigeria’s government has said the Boko Haram insurgency, and the rival Islamic State West Africa Province group, are on their last legs.

But sustained efforts to eradicate the militants have failed and the military continues to suffer heavy losses.

The war has killed more than 30,000 people and displaced millions more.

The soldiers were evacuating villages in the region on Saturday to carry out operations against Boko Haram, the sources said. One said the civilian convoy had as many as 50 vehicles.

Nigerian military spokesmen did not respond to requests for comment.

On Wednesday, Islamic State’s West Africa branch claimed responsibility for a raid in Nigeria in which it said 20 soldiers had been killed, and released a video purporting to show the execution of nine other Nigerian soldiers.