"Defence Minister Abdullah Habibi and Army Chief of Staff Qadam Shah Shahim stepped down with immediate effect," the presidential palace announced in a post on its Twitter account.
Shah Hussain Murtazawi, acting spokesman for Ghani, told Reuters the resignations were because of Friday's attack on a major army base in the northern city of Mazar-i-Sharif.
In a serious security failure, as many as 10 Taliban fighters, dressed in Afghan army uniforms and driving military vehicles, made their way onto the base and opened fire on soldiers and new recruits eating a meal and leaving a mosque after Friday prayers, according to officials.
Multiple Afghan officials said the final death toll was likely to be even higher.
The attackers used rocket-propelled grenades, machine guns, and suicide vests, they said.
Ghani declared Sunday a day of mourning, ordering flags to be flown at half staff.
On Monday, a small group of demonstrators gathered outside the presidential palace in Kabul to demand the resignation of top Afghan defence officials over the attack.
The attack, and resulting military leadership shake-up, come as the Afghan army prepares for what is expected to be a year of hard fighting against Taliban militants, who now control or contest more than 40 percent of the country.
Nearly 9,000 US troops remain in Afghanistan, in addition to thousands of international coalition forces.
The administration of new US President Donald Trump is considering whether to make changes to the US mission training and advising Afghan forces, and conducting raids against militant groups such as Islamic State.
The German military, which has led much of the advising effort in northern Afghanistan, said in the wake of the attack it would continue to work with the Afghans.
(Reporting by Josh Smith and Mirwais Harooni; Editing by Alex Richardson)
© Thomson Reuters 2017
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)