* Lawyers advised sacking cabinet unconstitutional
* Ugandan peacekeeper killed
By Abdi Guled and Ibrahim Mohamed
MOGADISHU, May 20 Somalia's president reinstated Prime Minister Omar Abdirashid Sharmarke and his cabinet on Thursday after days of uncertainty following a parliamentary vote of no confidence in them.
President Sheikh Sharif Sheikh Ahmed asked Sharmarke and his ministers to step down after the vote on Sunday. A total 280 MPs had chosen to sack them, according to former speaker Sheikh Aden Madobe, who has since resigned.
"Why I replaced the prime minister was because I was referring to a letter from the former speaker, but I have ordered the government to continue its duties because when I discussed with lawyers, they said it was unconstitutional," Ahmed said in a statement.
Sharmarke refused to leave his position and maintained that parliament's move was unconstitutional.
The chamber, whose business has been paralysed because many legislators live in Kenya, Europe and America because of security fears in the war-riven country, met on Sunday for the first time since December.
One analyst said Ahmed's action to reinstate the prime minister was probably just a temporary solution to keep the government together until he could get parliament to remove him properly.
"It's like an aspirin, its not a cure," said Abdirahman Moalim Badiyow, history professor at Mogadishu University.
"There is a fundamental problem in that he has already said he is not satisfied with the government. He is just minimising the scope of the conflict now, and probably after parliament elects a new speaker, it will deal with the government."
The Horn of African country has been deprived of effective central government for nearly 20 years and Ahmed's Western-backed administration controls no more than a few blocks of Mogadishu, with the help of African Union troops.
It is beset by near-daily attacks from the Islamist al Shabaab group, which Washington terms as al Qaeda's proxy in the region, and Hizbul Islam, another hardline group.
The AU AMISOM peace mission bolstering it in Mogadishu has just under 7,000 troops, according to the United Nations, and its soldiers are also under frequent attacks from roadside bombs and rebel artillery.
One such attack killed a Ugandan soldier on a foot patrol on Thursday.
"We have lost one soldier after a roadside bomb blast struck our foot patrol," AMISOM spokesman Major Barigye Ba-hoku told Reuters. "It was a barbaric attack by the anti-peace elements who don't like peace for Somalia."
The African Union has asked its member states to boost the troops numbers but only Uganda and Burundi have done so.
In a separate attack, two children were killed when a mortar fired in the direction of the parliament landed on a house. (Additional reporting by Sahra Abdi; editing by Helen Nyambura-Mwaura and Charles Dick)
Our top photos from the past week.