KAMPALA, Uganda — Twelve Ugandan soldiers were killed and seven others injured in an ambush by al-Shabab Islamic extremists in southern Somalia on Sunday, Uganda’s military said Monday.

The troops are deployed to Somalia as peacekeepers under the banner of the African Union.

The Ugandans were conducting a joint patrol with Somali forces when they were attacked in Lower Shabelle region, according to Ugandan authorities.

There was no word on any casualties among the Somali forces.

Al-Shabab claimed it killed 39 soldiers. It was not possible to verify the claim; the group frequently inflates death tolls from attacks carried out by its fighters.

Sunday’s attack came hours after a car bomb in Somalia’s capital killed at least five people, most of them civilians, shattering a month of relative calm in Mogadishu.

The al-Qaida-linked al-Shabab is the deadliest Islamic extremist group in Africa. It maintains a presence largely in Somalia’s rural areas and continues to pose major challenges to the allied Somali and African Union forces, even as the AU force plans to pull out of Somalia in the coming years and leave security to Somali troops.

Hundreds of African Union soldiers have been killed in recent years as al-Shabab targets their military bases as well.

Sunday’s ambush was one of the deadliest attacks on Ugandan forces in recent years. In September 2015 al-Shabab killed at least 19 Ugandan soldiers at a military base in Janale, southwest of Mogadishu.

Al-Shabab is opposed to the presence of foreign troops inside Somalia and has mounted deadly attacks in the capitals of Uganda and Kenya, which also has troops in Somalia.