Mortars fired by Islamic militants slammed into Somalia's airport as the president was boarding a plane Thursday, sparking battles that killed at least 24 people when return fire hit residential areas and a market, officials said.

The president was unhurt and his plane took off safely, police said, but the deaths of civilians is fueling a growing anger toward African Union peacekeeping forces that are stationed in Mogadishu to help protect the U.N.-backed government.

Somalia's capital sees near-daily bloodshed as a powerful insurgent group with links to al-Qaida tries to overthrow the fragile government and push out some 5,000 AU peacekeepers. Both sides have been accused of indiscriminate shelling.

At least 20 bodies, most of them civilians, lay in the streets after Thursday's fighting, said Ali Muse, the head of Mogadishu's ambulance service. Four people later died at the hospital. Muse said about 60 people were wounded as mortar rounds slammed into residential areas.

The shelling started soon after insurgents fired toward President Sheik Sharif Sheik Ahmed's plane, said police spokesman Abdullahi Hassan Barise.

Thursday's violence — deadlier than many recent clashes in this once-beautiful seaside city — follow a pattern that witnesses say is becoming all too common. First, insurgents fire at government or AU targets. Then those forces respond by shelling insurgent bases, most of which lie in residential areas.

The result is that most of those killed in Somalia's war are civilians.

The same situation has exists in Afghanistan, where U.S. and NATO forces are battling Taliban militants. The militants fire on international troops from residential areas in hopes of drawing return fire that kills civilians — a propaganda victory for the militants. The U.S. commander in Afghanistan has sought to reduce such return fire, which turns Afghans against U.S. and NATO forces.

But in Somalia, the AU denies firing into residential areas. AU peacekeeping force spokesman Barigye Bahoku said insurgents are actually shelling the residential areas they control to make it appear the AU is responsible. But many Somalis doubt such assertions.

"What cannot be denied is that most of the fire comes from the bases of the African Union, and they hit and kill civilians in the rebel-controlled areas," said Ahmed Abdulahi, a businessman in Mogadishu. "People have eyes and ears, they know what is going on."

Sheik Ali Mohamud Siyad, the trader's chairman of Bakara Market which was hit with mortar shells Thursday, said: "It is ruthless and inhumane to target innocent civilians, but it happens every day here and nobody bothers to mention it."

Anger is growing toward a peacekeeping force that has long lamented that it is undermanned. The force is meant to have 8,000 troops, but reinforcements have not arrived. The troops, from Uganda and Burundi, come under regular attack and mostly are confined to bases in Mogadishu for safety.

Somalia has not had an effective government for 18 years, since warlords overthrew longtime dictator Mohamed Siad Barre. The warlords then turned on each other, plunging the Horn of Africa nation into chaos and anarchy.

Somalia's lawlessness also has allowed piracy to flourish off its coast, making the waterway one of the most dangerous in the world.