When a small car bomb exploded outside a courthouse in the bustling port city of Bosaso in northern Somalia, local news reports chalked it up to Islamist militants retaliating for American airstrikes. At least eight people were wounded, and a local affiliate of the Islamic State claimed responsibility.

The attack, however, may have also been part of a very different conflict: one among wealthy Persian Gulf monarchies competing for power and profits across the Horn of Africa.

Over the last two years, war-torn Somalia has emerged as a central battleground, with the United Arab Emirates and Qatar each providing weapons or military training to favored factions, exchanging allegations about bribing local officials, and competing for contracts to manage ports or exploit natural resources.

In an audio recording obtained by The New York Times of a cellphone call with the Qatari ambassador to Somalia, a businessman close to the emir of Qatar said that the militants had carried out the bombing in Bosaso to advance Qatar’s interests by driving out its rival, the United Arab Emirates.