Kurdish troops carry a wounded colleague on June 14 in the eastern province of Diyala, where they’ve been helping to rescue stranded Iraqi soldiers. The Kurds’ military cooperation could be derailed by an operation that resulted in the death of six Kurdish fighters and injuring 43. (Stringer/Iraq/Reuters)

— Since al-Qaeda-linked renegades swept into northern Iraq, Kurdish forces have played a behind-the-scenes role in rescuing embattled Iraqi soldiers from checkpoints and bases, staving off more losses for the troops.

But a disastrous end to one such operation Saturday is threatening to derail their military cooperation against the militants from the Islamic State of Iraq and Syria (ISIS). Furious Kurdish military officials accused Iraqi forces of firing mortars and Hellfire missiles at Kurdish fighters, killing six and injuring 43.

Iraqi officials said the attack was a mistake. One Iraqi official, who spoke on the condition of anonymity because he was not authorized to speak to the media, said that the Kurdish troops had been asked to withdraw from that area. “You have to expect casualties in war,” he said.

The blunder highlights the state of the Iraqi military, which is reeling from the defection of as many as 90,000 of its 250,000 men and has allowed hundreds of millions of dollars’ worth of weapons to fall into the hands of militants inspired by al-Qaeda.

Saturday’s incident could cost the Iraqi government an essential ally. The Kurds, who live in a semiautonomous region in the north and have long maintained their own military forces, have been helping the Iraqi army in recent days despite a long history of tensions.

A senior Kurdish security official, who spoke on the condition of anonymity because he works in intelligence gathering, said Kurdish forces, known as pesh merga, were called upon by Iraqi authorities to help in rescuing Iraqi soldiers stranded in what was formerly the U.S. military’s forward operating base Cobra, in the eastern province of Diyala.

The Kurds provided support in the mission to rescue soldiers with 215 vehicles at the base, which was surrounded by ISIS forces, he said. The Iraqis “knew our exact location,” he said. “We gave them our coordinates.”

But six mortar rounds fell at 1:30 p.m., said Maj. Gen. Ibrahim Saleh, a pesh merga commander who was wounded in the incident. His assumption then was that the attack had been launched by ISIS. Two Kurdish soldiers died, and 21 others were wounded.

Around 4 p.m., the Kurdish position was attacked again, this time by two Iraqi helicopters firing U.S.-supplied Hellfire missiles, the official said, adding that he was “99 percent sure” that the attack was intentional — although he speculated that it might have been launched by local forces working without authority from Baghdad. Four soldiers died, he said.

“If this was a deliberate attack by the Iraqi armed forces, it was a huge betrayal,” said Saleh, speaking over the phone as he rested at home with shrapnel wounds.

An Iraqi government spokesman could not be reached Sunday night.

The rampage by al-Qaeda-linked militants across northern Iraq has left the Kurds in a position of strength. Before the fall of Mosul to militants and the collapse of much of Iraq’s military, the leadership in Irbil, the Iraqi Kurdish capital, had been locked in a dispute with Baghdad about budget allocations and oil revenue.

Since the Iraqi army withdrew from positions in Kirkuk, the Kurds have moved in to take over security in the ethnically mixed city, which they have always asserted should be under their authority. “Of course we are happy,” said Ahmed Askari, a member of Kirkuk’s provincial council and head of its security committee. “Not for the harming of Iraq, but we want our rights.”

While pesh merga have been called upon by the Iraqi government for small-scale assistance, any wider cooperation is unlikely, since Baghdad is worried that the Kurdish military assistance will strengthen the Kurds’ position.

The Kurdish security official said Iraq’s central government was often reluctant to take up Kurdish offers of assistance, including to secure two Diyala towns against ISIS before those towns fell on Friday.

While ISIS is focusing its fight elsewhere, it soon could threaten expanded Kurdish territory.

Gen. Sharko Fiteh, commander of the pesh merga’s First Division, said that when he heard that the Iraqi army had practically evaporated in Mosul, he urged the Iraqi commanders to stay and fight in the surrounding province of Nineveh. But the next morning, all 17,000 Iraqi troops in the region had melted away.

He said that the Kurds have no interest in maintaining control of areas to which their government does not lay claim. But as to whether the Iraqi army would be allowed back into contested areas, he said it is “too early to say.”