Seven Pakistani preachers were killed by several masked men at a mosque in Somalia's Puntland region on Wednesday, residents said.
Western security agencies said Somalia is a haven for insurgents plotting attacks in the region and beyond. Puntland is a base for pirates targeting the Gulf of Aden, but has been more peaceful than the south of the failed Horn of Africa state.
Residents said the attack took place after early morning prayers at the mosque in Galkayo in the semi-autonomous region, and was aimed at a group of 25 sheikhs who arrived on Tuesday.
"Six Pakistanis died on the spot while another Pakistani died from his injuries in the hospital. These men are Islamist preachers from Karachi, Pakistan," Hussein Abdullahi, chairman of Galkayo, told Reuters.
"Puntland forces have now surrounded the area around the mosque to protect the other sheikhs."
Somalia has been torn by civil war since 1991, and the government of President Sheikh Sharif Ahmed controls only small pockets of the rubble-strewn capital Mogadishu.
It is battling hardline Islamist rebels in southern and central regions, including the al Shabaab group, which the United States accuses of being al-Qaeda's proxy in Somalia.
Puntland's information minister was killed in the same area last week, and residents said Wednesday's attack may have been motivated by suspicions the preachers were linked to al-Qaeda.
Resident Sheikh Abdiqadir Ali said masked gunmen opened fire in the mosque immediately after prayers. A village elder said the bodies were removed from the scene by the security forces.
"There were 25 of these foreigners, mostly Pakistanis, and they arrived from Pakistan yesterday," the elder, Mohamed Hussein, told Reuters.
Abdullahi Said Samatar, Puntland's security minister, said the dead were preachers who travelled the world to spread Islam.
"We were very shocked to hear seven Pakistanis were killed in our region," he said.
Violence in Somalia has killed more than 18,000 people since the start of 2007 and driven another 1 million from their homes.
In a sign of international support for the Somali government, U.S. Secretary of State Hillary Clinton held talks with Ahmed in neighboring Kenya last week and pledged more aid for his fragile administration.