Somalia's parliament came under mortar fire on Monday as the country's newly elected lawmakers were meeting for only the second time since taking office, an attack claimed by the Islamist militant group Al-Shabaab.

Several people were reportedly injured but no lawmakers were harmed when several rounds of mortar shells landed near parliament in the heavily fortified compound in the capital Mogadishu, officials and a witness said.

The attack occurred as lawmakers were setting dates for parliamentary ballots to choose speakers for the lower and upper house -- the next stage in a stuttering process to elect the fragile nation's new president.

The new members of the Senate and the House of the People were sworn in on Thursday after elections held more than a year behind schedule that were marred by deadly violence and a power struggle between the current president and the prime minister.

The upper house will vote on April 26 to choose a speaker, with the lower house choosing its president the following day, officials said.

As Monday's parliamentary session was being streamed live on television several explosions were heard and lawmakers were told to stay inside.

"We have no details yet but these explosions were caused by mortar fire, the legislators were safe and unharmed inside the building when the incident occurred," a security officer who asked not to be named told AFP.

"I was in the area when the mortar shells landed outside the building where the parliamentarians were meeting, several people were wounded lightly in one of the blasts," witness Abdukadir Ali said.

Map of Somalia locating Mogadishu
Map of Somalia locating Mogadishu AFP / Sophie RAMIS

Al-Shabaab, the Al-Qaeda-linked jihadist group that has been waging an insurgency against the central government for more than a decade, claimed responsibility for the attack in a brief statement.

The UN mission in Somalia UNSOM issued a statement condemning the mortar attack.

It said it "stands firm with Somalis in their efforts to complete the electoral process and progress on national priorities."

Some parliamentary seats remain unfilled but sufficient lawmakers have been sworn in to move the election process forward.

So far, 297 have taken the oath of office, from a possible 329 members for both houses.

Somalia has not held a one-person, one-vote election in 50 years.

Instead, elections follow a complex indirect model, whereby state legislatures and clan delegates pick lawmakers for the national parliament, who in turn choose the president.