MOGADISHU (Reuters) - The speaker of Somalia’s parliament, Mohamed Sheikh Osman Jawari, has resigned ahead of a confidence motion against him, a lawmaker said, ending weeks of political tension.

“We were in the parliament house this morning ready for the motion against the speaker. Then the deputy speaker came in and read a resignation letter from the speaker,” lawmaker Dahir Amin Jesow told Reuters.

“We applauded and his resignation was accepted as per the constitution. That is the end of the political crisis.”

Jawari had held his position since 2013 and has clashed with other lawmakers, including over a decision to withdraw an impeachment motion against the then president Hassan Sheikh Mohamud in 2015.

Somalia has been in a state of lawlessness since the early 1990s, when dictator Mohammed Siad Barre was toppled by warlords.

It has also had to contend with al Qaeda-linked al Shabaab which carries out frequent attacks in Mogadishu and other regions, in a campaign to topple the government.