One of the projectiles hit a police unit, killing one policeman and injuring four, police said.
The Somali parliament was in session at the time of the attack, though the prime minister and speaker had just left.
"The mortars started to land near the parliament building when the session ended and the MPs had just passed a national budget," Osman Ilmi Boqore, the deputy parliament speaker, said.
No group had immediately claimed responsibility for the attack
Armed groups have taken control of sizeable parts of Somalia.
Just days before the attack, Sheikh Hassan Dahir Aweys, the Islamist opposition leader, returned from exile and said fighters would continue their battle against the government.