The Wrong Enemy: America in Afghanistan, 2001-2014. By Carlotta Gall. Houghton Mifflin Harcourt; 329 pages; $28. Buy from Amazon.com, Amazon.co.uk

FEW observers are better placed than Carlotta Gall to judge what has gone so badly wrong in Pakistan and Afghanistan since 2001. She spent more than a decade reporting for the New York Times in both countries, often from remote corners. She has a family connection, too: her father, Sandy Gall, is a British television journalist who covered Afghanistan for many years, notably during the war of the 1980s.

In “The Wrong Enemy” Ms Gall offers a provocative and compelling thesis: that America and its allies are leaving Afghanistan as a weakened state, plagued by violence and vulnerable to ambitions of its neighbours. That is despite the deaths of perhaps 70,000 Afghans, 3,400 foreign soldiers and a trillion-dollar bill. Yet the outcome was probably inevitable, since the West’s efforts were badly misdirected. In the words of America’s late special envoy to the region, Richard Holbrooke: “We may be fighting the wrong enemy in the wrong country.”

Ms Gall argues that since the Islamist movement is “rotting at the core”, the Taliban alone could have been crushed or accommodated long ago. It survived because it serves as a front for the far stronger Pakistani army, in particular the “S Directorate” of its spy network, the Inter-Services Intelligence (ISI). Pakistan uses the Taliban to project military power across the border.

The author shows how the ISI provides havens for the Taliban and directs them to attack Western forces. In Pakistan they develop suicide-bombing techniques and raise soldiers from madrassas. Each school has a talent-spotter paid to recruit students for militant outfits, who are referred to derisively by Pakistan’s army as “potato soldiers”. At crucial moments Pakistanis themselves have directly overseen operations, like the bombing in 2008 of India’s embassy in Kabul, which was “sanctioned and monitored by the most senior officials in Pakistani intelligence”.

More controversially, Ms Gall gathers evidence that senior elements of the Pakistani army collaborated with al-Qaeda, even as it drew billions of dollars from America to fight the militant Islamist group. Afghan intelligence sources “become convinced” early on of the relationship, she says, describing how in February 2006 the Afghan president, Hamid Karzai, and his spy chief personally handed a file to Pakistan’s dictator, Pervez Musharraf, giving evidence of al-Qaeda operatives hidden in safe houses in Abbottabad, a military town north of Islamabad. Mr Musharraf looked anxious, but did not act.

Five years on American special forces killed Osama bin Laden, also in Abbottabad. The natural question was whether Pakistan’s army had been sheltering him all along. Ms Gall says the Americans quickly concluded that it had, and that the head of the ISI, Ahmad Shuja Pasha, and possibly the army chief, Ashfaq Parvez Kayani, as well were aware of bin Laden’s presence. Ms Gall implies that Mr Musharraf probably also knew, though her evidence for this is weak. She says that the ISI had a desk dedicated to looking after al-Qaeda’s leader, while correspondence found in his house showed that he and aides had discussed doing a deal with Pakistan to refrain from terrorism in the country in return for protection.

Other evidence also points to a relationship. Mobile phones are routinely monitored in Pakistan, yet officials chose to ignore the fact that calls were being made to Saudi Arabia from mobiles inside bin Laden’s home. And even though the house was in a high-security area police did not check on it, suggesting that someone in the ISI vouched for the occupants. That bin Laden’s house had little protection also pointed to his reliance on others to guard him.

The book asks many of the right questions about the affair, and history may well prove Ms Gall’s answers to be right. Why, for example, would the American government not make public its conclusion about Pakistan’s complicity with al-Qaeda? Ms Gall suggests it cared more about trying to preserve its relations with a nuclear-armed ally. She may also turn out to be correct in suggesting that Mr Musharraf and ten senior generals knew of militants’ plans to kill Benazir Bhutto in 2007, but chose not to protect her. He is now on trial for treason in Islamabad in a separate case.

Ms Gall’s narrative would have been stronger if she had balanced what she learned from Afghan intelligence sources, who are famously hostile (if for good reason) towards Pakistan’s army, with other views. A better sense of context would also have made her argument more powerful. Why did the West choose not to confront the ISI, Ms Gall’s “right” enemy, despite abundant evidence of its wrongdoing? Was it fear of instability and the rise of Islamist groups across South Asia, the need for Pakistan’s help in promoting counter-terrorism in the West or anxiety about China’s growing influence? “The Wrong Enemy” is a strong, well-crafted account by an informed observer. It could have been even stronger.