The al Qaeda-allied group has stepped up its gun and bomb attacks in the Horn of Africa nation over the past week. Six people were killed in an attack on a vehicle carrying U.N. staff in the semi-autonomous Puntland region on Monday, and a suicide bomber killed 10 in a restaurant in Mogadishu on Tuesday.
Gunmen shot dead the former lawmaker and two city council officials on Saturday, and a senior prison officer was killed near the Bakara market in Mogadishu on Sunday, Major Nur Afrah, a police officer, told Reuters.
Al Shabaab claimed responsibility for all the killings and vowed to carry out more attacks.
"We killed the lawmaker, the two city officials and the prison colonel on Saturday and Sunday. We shall continue killing them," Sheikh Abdiasis Abu Musab, al Shabaab's military operations spokesman, told Reuters.
The militant group has carried out regular attacks in Somalia and neighbouring countries aimed at imposing its strict interpretation of Islamic law and overthrowing the Somali government, which is backed by Western donors and African peacekeepers.
It often targets officials and politicians for assassination.
The group, which once controlled Mogadishu and large chunks of territory in other regions, was driven out of the capital in 2011 and has been losing ground since then. But it still launches frequent guerrilla-style attacks and has struck across the border in Kenya.
This month, it claimed responsibility for an attack on a university in northeast Kenya that killed 148 people.