A suicide bomber detonated an explosives-laden car at a police station in the Somali capital Monday, killing at least eight people and wounding 35, a police officer said. The country's most dangerous militant group claimed responsibility.

The attack came after a weekend of fierce battles that saw African Union troops discover and destroy a mile-long trench used by insurgents to move fighters and ammunition in and out of the government-controlled area of Mogadishu. The AU said six al-Qaida-linked foreign fighters were killed during the fighting, which killed 16 people in total.

Monday's target was a training station for government troops. The car exploded around 7:40 a.m. only 10 meters (yards) beyond a security gate after police fired at the bomber, said Mukhtar Ali, a witness.

Thick smoke rose into the sky after the explosion, which scattered human remains near the station. Eight people were killed, said a police officer, Mohamed Abdi. Thirty-five people were wounded, the government said.

"If the car could have got deeper inside, there would be have been a big loss," Abdi said.

Sheik Ali Mohamud Rage, the spokesman for al-Shabab, a militant group populated by foreign fighters from the Middle East, claimed responsibility for the attack and said it was aimed at soldiers "who were being prepared to attack us."

Somalia's government called the assault "a cowardly act" carried out by hardliners. Islamist insurgent groups have used suicide bombers in the past in an attempt to bring down the fragile government, which is supported by 8,000 African Union peacekeepers.

"The armed forces will not to be deterred by such acts of violence and they will continue all necessary measures for (the) elimination of extremism and terrorism from the country," said Information Minister Abdulkareem Jama.

Jama's statement said two children — ages 10 and 11 — were among the dead.

Al-Shabab, Somalia's most dangerous militant group, merged last year with another group — Hizbul Islam — a move they said would help them concentrate on fighting the Mogadishu-based government and the African Union troops who protect it.

Militant veterans of the Iraq and Afghanistan conflicts help train al-Shabab fighters, one of the reasons the sophistication of its attacks has risen.

The country's transitional government is so powerless that the militants have confined it to a few blocks of the capital, while most of the country's southern and central regions are in the hands of the Islamists.

Somalia's capital, Mogadishu, has been the epicenter of the country's two decades of violence.

Monday's attack came after two days of fighting between pro-government forces and Islamists in the capital. Officials said six al-Qaida-connected foreign fighters and two African Union soldiers were among 16 people killed in the weekend battles.

The discovery of the trench provoked two days of heavy fighting in an area near the popular Bakara market, which is controlled by militants.