At least seven civilians were killed and 18 others wounded in fighting between al-Shabab and government forces backed by the AU troops, police in the capital said.
The parliament was meeting for the first time since al-Shabab and Hizb al-Islam groups launched an anti-government offensive in May.
"Several mortar shells struck the compound where we were having a session but there were no casualties. The session was called off after the attack and will continue tomorrow," Mohamed Adan, a legislator said.
Some 300 MPs were meeting in a building in the south of the capital Mogadishu when al-Shabab fighters began firing mortars.
"We heard explosions of mortar as we started our session minutes after the president left the compound," said Hussein Ali, another MP.