The Islamist group al-Shabab seized a town northwest of Somalia's capital from government forces on Sunday, the latest small center taken by the militant group trying to topple the country's Western-backed government.

Shabab, which once ruled much of Somalia, has been fighting for years to impose its strict interpretation of Islam on Somalia. African Union and Somali troops have driven it from major urban strongholds and ports, but they have often struggled to defend smaller, more remote areas from attacks.

"Many al-Shabab fighters attacked us this morning and after brief fighting we left the town for tactical reasons," Somali Army Maj. Hussein Edin told Reuters from the nearby town of Baidoa. One Somali soldier was killed, he said.

Goofgaduud lies about 250 km (160 miles) northwest of Mogadishu, the capital.

Shabab's military operations spokesman, Sheikh Abdiasis Abu Musab, confirmed the group had captured the settlement. He said seven Somali soldiers were killed.

Shabab's casualty figures and those announced by officials often differ.

In a separate incident, Somali forces in the semi-autonomous Galmudug region north of Mogadishu freed a Kenyan woman, Loise Njoki Weru, who officials said was held by pirates since 2015.

Galmudug Vice President Mohamed Hashi said she was now in safe hands after security forces rescued her and had spoken to her family, but he did not say when she would be repatriated.

Earlier this month, 26 Asian sailors were freed after more than four years of captivity in a small fishing village in Somalia after being held by pirates.