KABUL - The head of Afghanistan’s main intelligence agency, the National Directorate of Security, resigned yesterday over disagreements with President Ashraf Ghani, laying bare divisions that have hindered efforts to fight the growing Taliban insurgency.

The resignation of Rahmatullah Nabil follows a series of setbacks in recent months including the fall of the northern city of Kunduz to the Taliban and a raid on Kandahar airport in the south on Tuesday in which 50 civilians, police and security personnel were killed.

Relations between Ghani and the NDS have been strained since at least the fall of Kunduz, which an inquiry last month blamed on poor leadership.

Later, Ghani dismissed some NDS officials including the provincial chief of the agency who he said had neglected their duty to defend Kunduz.

In the letter, Nabil said that over the past few months, there had been “a lack of agreement on some policy matters” and the president had imposed unacceptable conditions on his ability to do his job.

He said Ghani’s “repeated verbal summons” had put him under impossible pressure and forced his resignation.

Ghani later issued a statement saying he had not wanted Nabil to resign because of the difficult security situation but he respected the decision.

The resignation raises fresh questions over the leadership of Afghanistan’s security apparatus, which has struggled to contain a Taliban insurgency that has gained momentum since international forces ended most combat operations last year.

Already without a permanent defence minister, due to disagreements between partners in Ghani’s national unity government, the country now has no spy chief just as the raid in Kandahar underlined the Taliban’s ability to inflict serious damage on government forces.

The Taliban, which also seized the important district of Khanishin in Helmand province, said in a statement that the operation had succeeded in “humiliating” the government “by sending a message that the Mujahideen are able to reach the most secure enemy locations undetected.”

The resignation, a day after Ghani attended the Heart of Asia peace conference in Islamabad, also clouds prospects for a coordinated effort to resume peace talks including both the Taliban and Pakistan that were broken off this year.

In an angrily worded post on Facebook that appeared before the resignation letter was made public, Nabil made clear his frustration with efforts to work with Pakistan, which many in Afghanistan accuse of controlling the Taliban.

He said the blood of innocent people spilled in recent attacks was “the same colour as the red carpet we trod like a catwalk”. The resignation comes a day after Nabil posted to his Facebook page a lengthy criticism of Ghani’s December 9 visit to Pakistan to attend a regional conference hosted by Pakistan’s Prime Minister Nawaz Sharif.

Nabil, who has blamed Pakistan for supporting Taliban militants in Afghanistan, also objected to Sharif’s December 9 claim at the Islamabad conference that “the enemies of Afghanistan are Pakistan’s enemies.”

Nabil said that while Sharif was making that statement, Taliban militants were beheading and killing innocent Afghan civilians at Kandahar Airfield and in the provinces of Helmand, Takhar, and Badkhshan. Ghani’s office announced on December 10 that Ghani has appointed Mohammad Masud Andarabi as the acting head of the National Directorate of Security. Andarabi previously was the deputy director of operations at the Afghan intelligence agency. “Nabil’s resignation highlights the challenges Ghani faces over his diplomatic outreach to Pakistan,” said Kabul-based military analyst Mirza Mohammad Yarmand.