MOGADISHU (Reuters) - Somalia’s parliament elected a former defense minister as its speaker on Monday.

Mohamed Mursal Abdirahman resigned as minister earlier this month to stand for the position after the previous speaker resigned ahead of a confidence motion against him.

Abdirahman secured over half of the votes from lawmakers that took part in the vote, deputy speaker Abdiwali Ibrahim Muudey said.

The previous speaker, Mohamed Sheikh Osman Jawari, had held his position since 2013 but quit after a dispute with the president that analysts said was fueled in part by a crisis in the Gulf spilling into the Horn of Africa country.

The president and the former speaker have long been rivals, analysts say. But much of their recent enmity was fueled by the perception that they back opposite sides in the dispute that erupted last year between Qatar and Turkey against Saudi Arabia and its ally, the United Arab Emirates (UAE).

“I assure the Somali citizens that I will honestly serve the country in accordance with the interest of the religion, people and the country,” Abdirahman said after the result of parliament’s vote was announced.

Somalia has been in a state of lawlessness since 1991, when warlords overthrew dictator Siad Barre and then turned on each other.