The resignation of Rahmatullah Nabil comes as Afghanistan grapples with string of major Taliban attacks, including a 27-hour siege of Kandahar airport this week which killed at least 50 people.
In his resignation letter, Nabil citied “a lack of agreement on policy matters” and restrictions imposed by the president which he alleged had hindered his ability to do his job.
The development comes a day after Nabil posted a scathing Facebook post criticising Ghani’s high-profile visit to Pakistan, the Taliban’s historic backer, on Wednesday for a regional conference.
“Our innocent countrymen were being martyred and beheaded in Kandahar airfield… at the moment when (Pakistan) Prime Minister Nawaz Sharif once again called Afghanistan as Pakistan’s enemy,” he wrote.
The office of the president was not immediately reachable for comment.
Ghani’s willingness to visit Afghanistan’s longtime nemesis signalled a renewed push to mend badly frayed cross-border ties, which could help jumpstart long-stalled peace talks with the insurgents.
Pakistan, which wields considerable influence over the Taliban, hosted a milestone first round of peace negotiations in July.
But the talks stalled when the Taliban belatedly confirmed the death of longtime leader Mullah Omar.
“Nabil’s resignation highlights the challenges Ghani faces over his diplomatic outreach to Pakistan, long blamed for the turmoil Afghanistan faces,” said Kabul-based military analyst Mirza Mohammad Yarmand.
Ties between Ghani and Nabil have been strained since the Taliban’s three-day capture of northern Kunduz city in September, which marked their biggest success in 14 years of war.
His resignation comes as a setback for Afghanistan’s security establishment, already without a permanent defence minister and struggling to rein in the ascendant insurgency.
Eleven Taliban suicide attackers on Tuesday breached the high-security Kandahar air field, which also houses a joint NATO-Afghan base, taking women and children hostage and triggering pitched firefights with soldiers.