Two soldiers were arrested in the shooting, but the motivations were not clear, including whether it was an accident. The Somali cabinet later fired the auditor general, Nor Farah Jimale, whose guards, according to the police, shot Mr. Siraji.

The death was a vivid reminder of the dangers facing even high-level officials in Somalia, an anarchic nation in the Horn of Africa where the United States is fighting a campaign against the Islamist militant group known as the Shabab. The country has been in varying states of chaos since the United States pulled out after the deaths of 18 soldiers in 1993.

On Twitter, Sagal Bihi, a member of Parliament, remembered Mr. Siraji as “humble and patriotic,” and an example of the “struggle & hard work” that had helped rebuild the country.

Born in 1986 in Afmadow, a town in the Middle Jubba region of Somalia, Mr. Siraji was raised at the Dadaab camp in Kenya — often described as the world’s largest refugee camp — where he lived for more than 20 years. He finished high school there, and he received a bachelor’s degree in computer science in Nairobi.

Two weeks ago, Mr. Siraji spoke at a TEDx event in Mogadishu, and he urged young people to help rebuild the country. “I asked myself, What can you do for your country?” he said of his own path.