Somali government officials arrived at the base with tight security
At least 16 people have died following a double suicide attack on peacekeepers in the Somali capital, Mogadishu, claimed by Islamist insurgents.
Among the dead is the deputy commander of the African Union force in Somalia, along with four bombers, an AU spokesman told the BBC.
A security official said two white vehicles with UN logos, but packed with explosives, drove into the base.
The al-Shabab group said the attacks were revenge for a US raid on Monday.
This reportedly killed Kenyan-born al-Qaeda suspect Saleh Ali Saleh Nabhan, who was wanted by the US for attacks in Kenya.
"We have got our revenge for our brother Nabhan. Two suicide car bombs targeting the AU base, praise Allah," al-Shabab spokesman Ali Mohamud Rage told Reuters news agency.
A spokesman for the force, known as Amisom, said that five government and AU officials were among those killed, including deputy commander Maj Gen Juvenal Niyonguruza, from Burundi.
He was about to complete his tour of duty, reports the AFP news agency.
Force commander Gen Nathan Mugisha, from Uganda, was lightly wounded.
An hour after the blasts, the BBC's Mohammed Olad Hassan saw missiles fired from the base near the airport towards Islamist-held parts of Mogadishu.
He says a young woman and a girl were killed. A medical official said seven people died in the missile attacks.
Our reporter says the suicide explosions rocked a large area of the capital. As soon as he heard them, he went to the roof of his house and saw palls of black smoke in the air.
A security official, who wished to remain anonymous, said the soldiers at the gate had assumed the vehicles were on UN business and let them enter the base.
"When the cars entered, one of them sped toward a petrol depot and exploded. The other one exploded in a nearby area," he said.
UN Secretary General Ban Ki-moon condemned the blast in the "strongest terms".
There are some 5,000 AU troops, mostly from Uganda and Burundi, in Mogadishu, protecting the weak, UN-backed government.
US officials say Nabhan was killed on Monday in a US military raid in southern Somalia.
He was wanted in connection with the 2002 attacks on a hotel and an Israeli airliner in his home city of Mombasa.
It is believed he fled to Somalia after the attacks and was working with al-Shabab, which the US sees as al-Qaeda's proxy in Somalia.
Earlier on Thursday, al-Shabab demanded that France ensure that AU forces are pulled out of Somalia.
This was one of several demands issued by the group for the release of a French security adviser captured in July.
Most of the AU troops in Somalia are from Uganda and Burundi
Al-Shabab and its allies control most of southern and central Somalia, while the government, helped by the AU force, just runs parts of Mogadishu.
The country has not had a functioning central government since 1991, leading to a complete breakdown of law and order both on land and in recent years in Somali waters.
President Sheikh Sharif Sheikh Ahmed, a moderate Islamist and former insurgent, was chosen in January after UN-brokered peace talks.
He has vowed to implement Sharia but al-Shabab accuses him of being a Western puppet.
Years of fighting and anarchy have left some three million people - half the population - needing food aid.