NAIROBI, Kenya — At least six people were killed, including two children, after a suicide bomber detonated an explosives-laden vehicle on Sunday outside a district headquarters in the Somali capital, Mogadishu, the authorities said.

Capt. Mohamed Hussein said the bomber tried to speed through a checkpoint but was stopped by security forces, prompting him to detonate the vehicle near the gate of Howlwadag district headquarters.

The Shabab, a Qaeda-linked extremist group based in Somalia, claimed responsibility for the attack, which shattered a period of calm in Mogadishu.

The three soldiers who stopped the truck were killed instantly, and three civilians also died, said Salah Hassan Omar, the spokesman for the Mogadishu mayor’s office.