By Stephen Kalin and Phil Stewart
BAGHDAD/WASHINGTON (Reuters) - The Iraqi army's failure to recapture the country's largest oil refinery from Islamic State after 15 months of fighting is calling into question the government's plans to retake the northern city of Mosul from the jihadists.
Iraq's military has been trying to build momentum at the Baiji refinery and in Anbar province in the west before attempting to seize Mosul, the biggest prize in the war against the ultra-hardine Sunni group.
Officials say the army should secure gains in those areas before setting its sights on Mosul, the largest city in the north. Advances in Anbar's vast desert terrain since the provincial capital Ramadi fell in May have progressed fitfully.
Taking the refinery and the nearby town of Baiji would boost the morale of the army as it tackles the gravest security threat since the fall of Saddam Hussein in 2003.
The military, plagued by corruption, nearly collapsed twice in the past year despite more than $20 billion in U.S. training.
Baiji, 190 km (120 miles) north of Baghdad, has repeatedly changed hands since it was captured by the militants in a lightning advance through Sunni Muslim provinces last year.
Government forces and their Shi'ite militia allies, backed by U.S.-led air strikes, are facing Islamic State snipers, suicide bombers and roadside explosives in the area.
"The liberation of Mosul will have to be done by the Iraqi army and local tribes ... the Iraqi army will come from the south and Baiji is the first stumbling block as long as Daesh (Islamic State) is lodged there," said Joost Hiltermann, program director for the Middle East and North Africa at the International Crisis Group.
Islamic State has been withdrawing exhausted fighters from Baiji and replacing them with fresh forces from the north via the towns of Hawija and Sharqat, a tribal leader said.
The group, which declared a caliphate last year stretching across the border into Syria, continues to dispatch reinforcements despite losing about 500 fighters between mid-July and early September, a U.S. official told Reuters on the condition of anonymity.
"We have seen ISIL (Islamic State) continue to put a large amount of reinforcements into that fight, and they're paying a heavy price for it," Marine Corps Brigadier General Kevin Killea, chief of staff of the U.S.-led coalition operations, told Pentagon reporters earlier this month.
The group's fighters there are estimated between the high dozens and low hundreds, according to Baiji mayor Mahmoud al-Jabouri and a source in the Iraqi army's command center for Salahuddin province where the town is located.
The insurgents plant homemade explosive devices in houses and on roadsides, bogging down their enemies.
They have erected barricades on streets and posted snipers and machine gunners in houses and other tall buildings in some central districts they control, Jabouri said.
The militants detonate car bombs and clash with government forces without making significant advances on the ground.
Security forces have cut a supply line from the west, but Islamic State maintains routes between northern and eastern areas of Baiji to points further north, the military source said.
That allows it to undermine security forces at the refinery and prevent them from opening the main route through Baiji, critical for sending troops and supplies to any attempt to retake Mosul.
Complex tribal dynamics and oil wealth from the refinery have complicated government attempts to wrest control of Baiji from insurgents since the U.S. invasion in 2003, said Michael Knights, an Iraq expert at the Washington Institute think-tank.
"Nobody ever takes Baiji," he said. "It was out of bounds to multinational forces in Iraq the whole time. It was never liberated, it was never surged."
Knights said Baiji's fragmented tribes make it difficult to forge consensus among local leaders, while insurgents have used money from refining and smuggling oil to co-opt the local population.
Around 1,500 militia fighters arrived earlier this month to begin fortifying southern and western parts of Baiji with trenches and barriers, Jabouri and the military source said.
The fighters, including some from a group that includes Iraqi Shi'ite militias who have fought alongside troops loyal to Syrian President Bashar al-Assad, supplement 6,000 regular forces.
Iraqi counter-terrorism forces control southern and western districts of the town, while federal police hold some areas in the north, the military source said.
Other militia fighters, under the banner of government-run Hashid Shaabi or Popular Mobilization Forces, also operate in some eastern neighborhoods, the military source said.
A second U.S. official, speaking on condition of anonymity, described the situation as static, with Iraqi security forces controlling about 20 percent of both the refinery and the town and the rest of the area either contested or under Islamic State control. Reuters could not independently verify those estimates.
Spokesman Ahmed al-Asadi said the Hashid fighters numbered in the thousands.
"Throughout the past year, we have learned that in any fighting position the army alone cannot win and the Hashid alone cannot win," said Asadi.
However, that cooperation is threatened by regional rivalries on the battlefield and in Baghdad politics.
Prime Minister Haider al-Abadi faces resistance to the integration of the Hashid into the regular security forces and to reforms that would sideline politicians with ties to Iranian-backed militias.
Iraqi officials have said Shi'ite militias are reluctant to give up power amassed with Iranian backing, making it difficult to formulate unified battlefield strategy.
In addition, Hashid elements trained by Tehran oppose any U.S. military role in the battle against Islamic State.
Washington and Tehran are competing for influence in Baghdad but should not allow that rivalry to benefit Islamic State, said Hiltermann of the International Crisis Group.
"They have to share the battlefield and that can lead to lack of coordination and setbacks."
(Additional reporting by Saif Hameed in Baghdad and Isabel Coles in Erbil; Editing by Michael Georgy and Giles Elgood)