"The president of the republic, who is now outside the country, decided to cut his trip short to participate in the burial," said Prime Minister Hassan Ali Khaire.
Abbas Abdullahi Siraji, the 31-year-old public works minister, was killed on Wednesday when his vehicle was mistakenly shot at by government security guards outside the presidential palace.
"We are deeply saddened by the devastating news of the death of minister Abbas Siraji and we are passionately grieving with his family as they pass through this difficult time," Khaire said.
President Mohamed Abdullahi Mohamed, known by his nickname Farmajo, had travelled to neighbouring Ethiopia on Wednesday.
Mohamed said he had ordered an investigation into what he termed "this unfortunate tragedy".
Somali minister shot dead in car after being mistaken for militant
In a series of tweets the president said he would "make sure the perpetrators are brought to book", adding that Siraji, who he appointed to his cabinet in February, "was young, diligent and patriotic".
Siraji was killed when bodyguards tasked with protecting auditor-general Nur Jimale Farah mistook the minister, who was driving himself in a following vehicle, for an assailant.
"What happened was gunfire involving soldiers who had become suspicious of each other, and what happened was very bad, a brother was killed," Farah said.
"There is an investigation going on and we don't want to speculate about the details before the result," he added.
Many government officials, wealthy individuals and foreigners drive around Mogadishu with squads of armed bodyguards who are frequently nervy and trigger happy.
Shabaab militants linked to al Qaeda carry out regular bombings and assassinations targeting government officials, while it is rare for a government minister to drive himself, making mistaken identity a strong possibility.
Blast outside military base in Somalia capital wounds three
Siraji was born in Somalia but grew up and was educated in one of the world's biggest refugee camps, Dadaab in Kenya. He was elected MP last year and became a cabinet minister in February.
His story was seen as inspiring to many in a country that has suffered conflict and anarchy for the last 25 years and his death has been widely mourned, including on social media.
Former government minister Abdi Aynte wrote on Twitter of the "pain and agony" of Siraji's death while others posted videos of their grief on Facebook.
The pain & agony with @absiraj's murder is lacerating. Met him 25 minutes before he was killed. We were supposed to meet again tonight. RIP! pic.twitter.com/EhGwS6djee
— Abdi Aynte (@Aynte) May 3, 2017
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ