The resignations come as Somali security forces struggle to contain attacks by the al-Qaeda-linked group.
Defence Minister Abdirashid Abdullahi confirmed his resignation to AFP on Friday, but would not be drawn on the reasons behind his decision.
The prime minister’s office announced the resignation of Abdullahi and army chief Ahmed Mohamed Jimale Irfid on Thursday.
Somali President Mohamed Abdullahi Mohamed, widely known by his nickname Farmajo, appointed Irfid in April as he declared a fresh war on the Shabaab.
The militants emerged out of a bitter insurgency fighting Ethiopia, whose troops entered Somalia in a US-backed invasion in 2006 to topple the Islamic Courts Union that was then controlling Mogadishu.
While the group has lost large swathes of territory and was forced out of Mogadishu by African Union troops in 2011, the Shabaab continues to stage regular attacks in the capital and countryside.
The resignations are the latest blow to the fledgling government of the president, who took office in February.
In May the country’s 31-year-old public works minister was mistakenly shot dead by government security guards outside the presidential palace.
Download our app and read this and other great stories on the move. Available for Android and iOS.