Somali President Sheikh Sharif Ahmed denounced the blast, which caused the most casualties among young students waiting for exam results at the education ministry, as a "cruel and inhumane act of violence." Another 150 people were wounded.
The African Union force in Somalia (AMISOM) said a truck laden with drums of fuel rammed a checkpoint outside a compound housing government ministries in the K4 (Kilometre 4) area of Mogadishu, where students had gathered to register for scholarships offered by Turkey.
Hundreds of parents stood weeping outside the Madina Hospital in Mogadishu after being denied access for security reasons and nurses said they were overwhelmed.
The al Shabaab insurgents who carried out the attack later warned Somalis to stay away from government buildings and military bases. "More serious blasts are coming," spokesman Sheikh Ali Mohamud Rage told reporters.
Britain condemned the attack and France reasserted its support for the country's U.N.-backed transitional government.
The United Nations (U.N.) Secretary General Ban Ki Moon said he was appalled by the vicious attack.
"It is very difficult to prevent these types of terrorist attacks which we have consistently warned are likely to be on the increase," the U.N. special envoy to Somalia, Augustine Mahiga, said.
The government said no senior officials were hurt in the attack on the ministry buildings.
Scores of people with burns walked to a nearby hospital and police were trying to evacuate more students trapped inside the damaged buildings. Doctors said they were shocked by the number of casualties, in a city that has endured years of violence.
The International Committee of the Red Cross said more than 90 people, including five women and nine children, had been admitted to the Madina Hospital, many with burns and fractures.
The attack also comes at a time the government has just embarked on a 12-month political road map which is supposed to lead to elections for a new parliament and president by August 20 next year.