Witnesses said at least 15 rebel al-Shabab fighters and six policemen were killed in exchanges of gunfire and mortar bombs, which have rocked the coastal capital since Tuesday.
The latest violence has flared up just days after Sharif Ahmed, the new Somali president, returned to the coastal city to form an inclusive unity government - the 15th attempt in 18 years - to bring peace to the failed Horn of Africa state.
On Wednesday, al-Shabab seized control of the town of Hodur, near the Ethiopian border, from government-backed forces, residents and al-Shabab members told the AFP news agency.
Al-Shabab and allied groups control much of southern and central Somalia and want to impose their version of sharia (Islamic law) in the country.
The AU currently has about 3,200 soldiers from Uganda and Burundi in Somalia, where two years of fighting have killed more than 16,000 civilians and displaced millions from their homes.
More than a third of the population depend on aid, and large parts of Mogadishu lie empty and destroyed.
Al-Shabab and other anti-government groups regularly attack government troops and AU peacekeepers, in efforts to force them out of the country.
The rebel group gained support as one of the key factions waging war against Ethiopian troops who they said were propping up the country's previous government.
An Ethiopian withdrawal in January eased the fighting, but al-Shabab has since turned its fire on the AU force, Amisom, and the new government.
Regional diplomats hope the inclusion of Islamist groups in the new administration may marginalise groups like al-Shabab, which is on Washington's list of terrorist organisations and is known to have foreign fighters in its ranks.