By Paul Carsten

ABUJA (Reuters) - Islamist militants have killed hundreds of soldiers in attacks in northeastern Nigeria in recent weeks, security and military sources say, forcing a turnaround in the course of an insurgency which the government has frequently claimed to have vanquished.

The fatigued, ill-equipped government troops have reached breaking point, they said.

The setback in the war against Islamic State in West Africa (ISWA) and the Boko Haram insurgency from which it split in 2016 comes as President Muhammadu Buhari seeks a second term in elections next February.

(GRAPHIC: Islamist insurgencies in Nigeria - http://fingfx.thomsonreuters.com/gfx/rngs/NIGERIA-SECURITY/010062F043W/NIGERIA-SECURITY.jpg)

Buhari came to power in 2015 on a promise to defeat Boko Haram, and security has once again emerged as a main campaign issue.

In the past three weeks, according to military and security sources, ISWA killed 48 soldiers at a military base and, in a separate attack, left 32 dead in Gudumbali - a town to which thousands of refugees were ordered to return in June.

"The situation in the northeast is deteriorating," said one security source, speaking on condition of anonymity. "They are running out of weapons, ammo and basic equipment. They are exhausted."

Now, ISWA is winning almost all its battles with the military, security sources said.

That marks a contrast with the situation in early 2015 when the Nigerian army, backed by troops from neighboring countries, pushed Boko Haram off a swathe of land that the insurgents controlled.

Before the insurgency, Nigeria's northeast, sitting in the arid Sahel that skirts the Sahara's southern border, had for centuries been a hub of cross-continental trade through the desert and one of the country's agricultural breadbaskets.

ISWA's influence extends from the Lake Chad region, including in Niger and Chad itself, and stretches about 100 miles into the Nigerian states of Borno and Yobe, where government has in many areas all but vanished after a decade of conflict. It was not immediately clear how control of that territory has changed in recent months.

MILITARY DENIES

A military spokesman denied the army was losing most of its clashes with ISWA.

"It's not true," said Brigadier General John Agim, adding that no soldiers had died at Gudumbali.

Agim declined to show battle reports or comment on the rest of the situation, other than saying the military did not have enough equipment.

In one of the army's biggest defeats since Buhari came to power, an ISWA attack on a base in July killed at least 100 soldiers, according to people familiar with the matter. Many of the dead were interred in a mass burial, two sources said.

Other grueling battles have been fought - at least 45 soldiers killed in Gajiram in June, scores dead and missing after a convoy ambush in Boboshe in July, and 17 killed in Garunda in August. These are just some of the recent attacks, according to military and security personnel, that are taking a heavy toll on the military.

With each victory, ISWA gets stronger, collecting weapons, ammunition and vehicles abandoned by fleeing troops. Its tactics have also improved, using trucks mounted with heavy guns to pin down ill-equipped troops, as well as suicide-bombing vehicles.

"SITTING DUCKS"

"The military are a bit like sitting ducks, waiting for a very mobile and versatile enemy to strike at a weak point or another," said Vincent Foucher, who studies Boko Haram at the French National Centre for Science Research.

The military has kept details of its most recent challenges and defeats close, rarely acknowledging them or any loss of life, say security sources who have sought briefings.

Buhari's administration and the military continue to issue statements about victories against an insurgency aimed at creating an Islamic caliphate that dates back to 2009. Normality is returning to the northeast, it says.

"The country has been stable for the past three years," Defence Minister Mansur Dan Ali told Reuters last month.

However, the minister, discussing the Jilli attack, acknowledged that a strong and well-equipped insurgent force was capable of wiping out as many as 200 soldiers.

"A CRISIS OF MORALE"

Soldiers have become terrified of the insurgents, afraid to leave their bases, said a security source and a diplomat. While hundreds have died recently, hundreds more have deserted.

One retired general, speaking on condition of anonymity, described "a crisis of morale," linking the frequent allegations of human rights abuses - rape, torture, shake-downs and extra-judicial killing - to broken spirits.

The Nigerian military denies such accusations, though it set up a panel last year to probe allegations. Its findings have not been made public.

Last month, Nigerian special forces mutinied at an airport, refusing to be deployed after learning that after years in the northeast they were being rotated to another, more dangerous part of the region.

"Many of our troops have been in the theater for over two years," said one captain. "They don't know how their families, their wives and children, are."

Some soldiers said though they do get a few days of leave, it is often barely enough time to go from the field to their families before they must return.

Others said their wages and rations are often embezzled by their commanders, there is too little equipment, and many vehicles are broken and gathering rust. One said his men had to buy blankets from refugees for 300 naira ($1) each to keep warm.

The United States, Britain and France support the military, mostly through training and information-sharing, but it has struggled to secure arms supplies due to human rights concerns.

The United States and Nigeria this year finalised a $500-million deal for 12 Super Tucano fighter planes. British Prime Miniser Theresa May, on a visit to Nigeria last month, promised to increase military support in the war against the Islamists.

(Reporting by Paul Carsten in Abuja; Additional reporting by Ahmed Kingimi and Ola Lanre in Maiduguri; Editing by Alexis Akwagyiram and Angus MacSwan)