Al-Shabab overran an African Union base in southern Somalia early Tuesday, a Somali military official said, in the latest display of the Islamic extremists' capacity to hit back amid a prolonged offensive against them.

The attack in the small farming town of Janale started with a suicide car bombing at the base's gate, followed by a firefight which lasted more than an hour, said Col. Ahmed Hassan.

The African Union force in Somalia, known by its acronym as AMISOM, insisted on Twitter that it is still in control of the base.

However, Hassan told The Associated Press by phone that the militants overran the base after bombing a nearby bridge to prevent troops from escaping.

Al-Shabab said it killed about 50 AU troops from Uganda at the base. Al-Shabab spokesman Abdiaziz Abu Musab told the group's online Andalus radio station that the Ugandan contingent of the AU forces was targeted in retaliation over alleged killings by Ugandan troops of six men at a wedding in the nearby Somali port town of Merka in July. He also accused Ugandan troops of raping Somali women.

"Very few escaped," Abu Musab said, referring to Ugandan troops. "Others swam into the (Shabelle) river and drowned. Others might have escaped into the jungle."

Human Rights Watch last month urged an investigation into the wedding killings and called on the Ugandan government to prosecute any of its soldiers responsible for criminal offenses. Citing witnesses, the rights group reported that after a bomb attack on an AMISOM convoy, Ugandan forces entered several nearby houses in Merka's Rusiya neighborhood. At one house, where a family was celebrating a wedding, the soldiers separated the men from the women and shot six adult men, according to the group.

Despite losing possession of most of the capital and other key strongholds in south and central Somalia in recent years, al-Shabab continues to carry out attacks on the government and African Union troops across the Horn of Africa nation.

In June, al-shabab fighters overran another African Union base in Lego, a small town in the Lower Shabelle region in southern Somalia, killing dozens of soldiers and seizing military armaments.

Al-Shabab, which has ties with al-Qaida, has carried out attacks beyond Somalia's borders, targeting countries like Uganda and Kenya which have sent troops to fight the Islamic extremists under the banner of the African Union.

Al-Shabab carried out an attack on an upscale mall in the Kenyan capital of Nairobi in September 2013, killing at least 67 people. In April, the group claimed responsibility for a deadly attack on a university campus in northeast Kenya. At least 148 people were killed in that attack.