Galmadug security forces hold their weapons as they stand in a field near the central Somali town of Galkayo on Aug. 18, 2010. (Roberto Schmidt/Agence France-Presse via Getty Images)

An American drone strike thought to have struck Islamist militants in Somalia actually killed 10 members of a regional force allied with the United States, according to results of a Pentagon investigation that have not yet been made public.

The September incident sheds light on the escalating involvement of U.S. forces in Somalia’s protracted war against al-Shabab, a group of al-Qaeda-linked militants. It also points to the unforeseen consequences of increased U.S. drone strikes in a country still run by clan militias.

“They’ve helped us out against a common enemy,” a U.S. military official said Thursday, referring to the regional forces who were killed in the strike. “If we had known who they were, we would have done everything we could to prevent it.” He spoke on the condition of anonymity because the investigation’s findings are not yet public.

As the United States has waded further into Somalia, it has struggled to form a coalition of allies from a range of rival groups. Two of those groups — from the states of Puntland and Galmadug — have targeted and arrested al-Shabab terrorists, and received American accolades for doing so.

But the groups also have been fighting one another for decades, mostly over territory in the city of Galkayo.

On Sept. 28, Puntland security forces were sent to investigate a “suspicious group,” thought to be al-Shabab based on American surveillance imagery, according to the U.S. official.

American forces accompanied the patrol as advisers, until they neared the unknown group. It was early in the morning, and visibility was limited when Puntland forces “started taking fire,” said the U.S. official. They asked for air support, and the U.S. military launched the drone strike.

Shortly after the attack, officials in Galmadug began accusing the United States of killing its own allies. They released images of government vehicles destroyed by the strike. There were protests in the streets. People burned American flags.

In interviews with The Washington Post in a hospital in Mogadishu, the Somali capital, two survivors of the strike who belonged to the Galmadug forces described the way it had hammered their unit.

“Small aircraft, sounding like flies, started hovering over us,” said one survivor, Ali Adan Mohamed. “At about six in the morning the airstrike started, the aircraft fired three missiles.

“I believed that the U.S. was neutral, but now it seems to me that they have sided with one of two clans,” he said.

When Galmadug state officials heard what happened, they were furious with the Americans.

“There is not any justification that could lead to such disaster,” Minister Osman Ise Nur, the head of Galmadug’s security operations, said in a phone interview. “We were amazed with what has happened to our forces despite the fact that they were fighting al-Shabab.”

The U.S. Africa Command issued a statement shortly after the attack that described the target of the strike as “a group of armed al-Shabaab fighters.”

But a new Pentagon report, parts of which were described to The Washington Post, contradicts that initial conclusion.

“We responded and struck the hostile force with the belief that it was al-Shabab,” the U.S. official said. “But we recognize that they were Galmadug forces.”

In other words, the United States appeared to have unwittingly entered into a war between two regional fighting forces, both its allies.

More than 75,000 people have been displaced by the fighting between Puntland and Galmadug forces in recent months, and are “in dire need of humanitarian assistance,” according to Abdelgadir Galal Ahmed, the Norwegian Refugee Council’s country director.

Somalia has been torn apart by civil war for 25 years, resulting in chaos that allowed the rise of al-Shabab in 2005. The White House considers the group one of its top concerns in sub-Saharan Africa, in part because its attacks extend beyond Somalia to civilian targets in neighboring Kenya, including the bloody strike on Nairobi’s upscale Westgate Mall in 2013.

The United States has a particularly strong relationship with the Puntland forces and has for years helped to train them.

Although the U.S. Africa Command investigation found that the drone strike had inadvertently killed Galmadug forces, it nonetheless ruled that the action was “legitimate” in that it probably saved the lives of the United States’ Puntland allies.

“The strike was clearly lawful,” the U.S. military official said.

Not long after the strike, Stephen M. Schwartz, the newly appointed U.S. ambassador to Somalia, met with Abdikarim Hussein Guled, the president of Galmadug, and other local officials. Galmadug officials said the ambassador apologized for the strike. The State Department would not confirm the apology.

Unlike politicians in countries like Afghanistan, who have denounced U.S. drone strikes because of collateral damage, Somalia’s government has been supportive of the attacks aimed at al-Shabab.

“I heard that in Pakistan and Afghanistan, the experience of the drones was not good,” the country’s president, Hassan Sheikh Mohamud, said in an interview in April. “But here they are precise, and we are informed of them before.”

The drone strike and the controversy over it come just before Somalia’s presidential election, set for Nov. 30, and as Western donor nations are revising plans for the country’s national army, which is largely considered poorly structured, incompetent and unaccountable.

A new plan would provide more assistance to regional fighting forces, such as the one in Galmadug, which are seen as having more legitimacy in their own states, rather than just funding a national army that’s recruited largely from Mogadishu and not welcome in much of the fractured nation.

“We need to have a greater involvement of the regions, because the problem at the moment is the Somali National Army is seen as supporting one clan,” said a senior Western official, who spoke on the condition of anonymity because of sensitivity involving military planning. “It is not a national army, and it is more likely to provoke violence in some areas.”

Melding those regional forces into a single Somali fighting force is an enormous challenge. But the current situation, in which regional fighting forces target both al-Shabab and one another, is untenable, officials and experts say.

“We can’t have a state that has all sorts of armed forces lingering around with all sorts of loyalties,” said another Western official.

More than 20,000 troops are based in Somalia as part of the African Union’s mission there. Those troops are set to begin withdrawing in 2018, and the international community has been desperate to find a Somali solution to the country’s security problems.

The United States has pledged to defend its Somali partners while also targeting high-profile Islamist militants. It has conducted more than a dozen airstrikes and drone strikes in 2016, according to Defense Department statements.

Mustafa Haji Abdi in Mogadishu contributed to this report.