KABUL (Reuters) - The head of Afghanistan’s main intelligence agency resigned on Thursday over disagreements with President Ashraf Ghani, laying bare divisions that have hindered efforts to fight the growing Taliban insurgency.

Rahmatullah Nabil, head of Afghanistan's National Directorate Of Security (NDS), shows a paper during a joint news conference in Kabul September 7, 2011. REUTERS/Omar Sobhani

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 an insurgent raid on Kandahar airport in the south on Tuesday in which 50 civilians, police and security personnel were killed.

Already without a permanent defense minister due to conflicts within Ghani’s national unity government, the country now has no spy chief just as the Kandahar raid underlined the Taliban’s ability to inflict serious damage on its forces.

Nabil, who strongly opposed Ghani’s moves toward a rapprochement with Pakistan, said in his letter of resignation from the National Directorate of Security (NDS) that there had been “a lack of agreement on some policy matters” in recent months.

He said the president had imposed unacceptable conditions on the way he did his job, with “repeated verbal summons” that put him under impossible pressure and forced his resignation.

Relations between Ghani and the NDS had been strained since at least the fall of Kunduz, which caught security forces badly unprepared and 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. The Taliban held the city for several days before government troops could regain control.

DIFFICULT SECURITY SITUATION

Ghani issued a statement on Thursday saying he had not wanted Nabil to resign because of the difficult security situation but he respected the decision. An interim replacement would be named soon, he said.

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.

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

Thousands of civilians, soldiers and police have been killed as the Taliban has extended its grip on swathes of the country, piling pressure on Ghani and putting his awkward national unity government under increasing strain.

The president’s official Facebook page, which announced the resignation, was immediately flooded with hundreds of angry comments from Afghanistan’s active social media users, most of them abusing the government.

“Shame on the presidential palace, Nabil resigned because he was anti-Taliban and anti-Pakistan,” wrote one user in a comment typical of many others.

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

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 color as the red carpet we trod like a catwalk”.