Somali lawmakers approved a new cabinet on Monday, hours after Shebab insurgents assassinated a colleague as he made his way to parliament.
The killing in the capital Mogadishu is the latest in a string of assassinations of politicians in the war-torn east African country.
Speaker of parliament Mohamed Osman Jawari said that 191 out of 220 legislators present had endorsed the new cabinet, consisting of 26 ministers, plus 40 deputy ministers.
Security was beefed up in the volatile city ahead of the session, but gunmen managed to shoot dead an MP as he left to go cast his vote.
"Abdulahi Qayad Barre was shot dead, men killed him as he left his house to go to parliament," fellow MP Abdukarim Hajji said.
Barre is the first lawmaker to be assassinated this year. At least five MPs were killed in 2014.
The Al-Qaeda-affiliated Shebab rebels are fighting to overthrow the country's internationally-backed government.
The extremists say they are targeting MPs for allowing the deployment of foreign troops in Somalia.
"Shebab commandoes shot and killed Barre, and all the so-called MPs are a legitimate target subject to be killed or captured, to face the justice of Allah," Shebab spokesman Sheikh Abdul Aziz Abu Musab told AFP.
"This the fate of all non believers."
Shebab attacks in Somalia have targeted key government and security sites in an apparent bid to discredit claims by the authorities and African Union troops that they are winning the war against the group.
Somalia's parliament is also riven by political infighting. International donors have repeatedly warned that the power struggles are stalling progress towards stability.
However, lawmakers finally approved the new prime minister's last list of candidates.
Omar Abdirashid Ali Sharmarke, who was named prime minister in December, had been forced to revise his choices after MPs opposed his first proposed cabinet line-up.
Somalia is due to vote on a new constitution next year ahead of elections in 2016, but Shebab remains a major threat.