In the spring of 2002, the American army arrived in force in Afghanistan. Its main base was at the old airfield at Bagram, a short drive north of Kabul. By early summer, serried ranks of tents had gone up in the fine dust, a basic field hospital had been established and the all-important PX opened – where soldiers could buy Hershey bars, Hot Tamales candy, R&B compact discs and Bibles in "tactical" camouflage covers. In the evening, during the month I spent at the base, I went running on the airstrip, past the helicopters, the transport planes, the artillery park and the compound where prisoners were being kept. All around the perimeter, as dusk turned to night, newly arrived US troops tested their weapons, sending streams of tracer fire into the gathering darkness.

Over the following years, the base at Bagram grew rapidly. The old runway was renovated and extended, the makeshift jail converted to one of the most notorious detention facilities run for suspected al-Qaida and Taliban captives, power plants built and vast dining halls opened.

The tents were replaced by prefabricated and then solid concrete barracks. On one recent visit, I got my dinner from Burger King and, when waiting for a helicopter the next morning, watched Tropic Thunder, the spoof Vietnam war film, projected on the wall of a hangar. The old air base had become a small town of around 10,000 inhabitants, a Little America in the middle of an Afghan plain.

Little America is an apt title for this comprehensive, perceptive and detailed work. It is the second book by Rajiv Chandrasekaran, among the best of those brave, clever, and assiduous reporters that American journalism seems to produce in such happy abundance. His first, Imperial Life in the Emerald City, was a justly praised description of the follies, excesses, naivety and negligence of the Americans who tried to run Iraq with such disastrous results between 2003 and 2004.

In this new work he looks at the American experience in Afghanistan, focusing on the 2009 to 2011 period. That his book is already effectively a history – albeit a very contemporary history – says much about the rapidity with which the aims and methods of the west have changed in that tragic country over the last years. Little America is focused on the decision by President Obama to send around 30,000 new troops into Afghanistan in 2009 and its consequences. This "surge", modelled in part on a similar but more successful exercise in Iraq, is now over. Whether it worked or not is one of the many themes explored by Chandrasekaran in this book. The CIA apparently decided it had, at best, led to a stalemate.

"Where we went, we made a difference. But not next door," one official told the author. "The surge worked locally, but it did not have the nationwide effect that was advertised."

But the ultimate answer is that the debate is no longer relevant. Largely due to factors which have little to do with Afghanistan itself – the state of the American economy, general war fatigue in the US and elsewhere, the death of Osama bin Laden last year, the fragmentation and regionalisation of al-Qaida – the international project in the country is now winding down. In 2009 I asked the then US ambassador in Kabul if, as America was a democracy, any one leader could really promise eternal support. "Can I say we will be committed for the full life of the sun? No," he answered. "But short of that, yes, we will be here." That wasn't true.

As Chandrasekaran observes, it costs $1m to keep one American service member in Afghanistan for a year. The annual bill for the war last year was more than $100bn. Was achieving a marginally less bad outcome in Afghanistan worth the expense, administration officials wondered? With other pressing security challenges – Iran, North Korea, and the political upheaval in the Middle East – was it prudent to be committing so many resources to stabilising remote Afghan villages? The United States was spending more each year to keep marine battalions in two single remote districts in the deep south of the country than it was providing the entire nation of Egypt in military and development assistance, Chandrasekaran points out.

The war in Afghanistan started with goals that were purely to do with US security – the need to eradicate the bases from which the 11 September attacks had been launched. We have come full circle. The only debate now is whether what is left behind is enough to prevent a reconstituted al-Qaida gaining some kind of foothold. In the intervening period, the western project in Afghanistan was something much more ambitious, involving the creation of a prosperous, stable democracy with significantly improved human rights for women and minorities. The contrast with the modest aims of today is, at the very least, unedifying. There are stronger adjectives that could be used.

So what went wrong? First of all, winning in Afghanistan, however defined, was never going to be easy. The international effort there came at the end of a long series of increasingly ambitious – and even sometimes successful – "liberal humanitarian" interventions. It was a period of extraordinary hubris – and great trauma after the 9/11 attacks. Together this bred a toxic mix of astonishing overconfidence and deep insecurity. Then came the distraction of Iraq.

Chandrasekaran suggests – and some military historians might disagree – that Afghanistan is "by far the most complicated war the USA has ever prosecuted". The superlative here might be challenged by many historians but that the conflict was a tough challenge is without doubt.

America, however, could not meet it, he argues. Chandrasekaran's indictment is savage. "Too few generals recognised that surging forces could be counterproductive… Too few soldiers were ordered to leave their air-conditioned bases and live among the people in fly-infested villages. Too few diplomats invested the effort to understand the languages and cultures of the places in which they were stationed. Too few development experts were interested in anything other than making a buck. Too few officials in Washington were willing to assume the risks necessary to forge a lasting peace… Generals and diplomats were too ambitious and arrogant. Uniformed and civilian bureaucracies were rife with internal rivalries. Our development experts were inept. Our leaders were distracted." The result, inevitably, was that "the good war… turned bad".

And if, after reading this, any Europeans are feeling smug, they shouldn't. Where they are mentioned at all, allies are portrayed as incompetent, feckless, cowardly or complacent. The British, whose ineffectual attempts to secure Helmand province and appalling relations with both local communities and the Americans are described in painful detail, come out particularly badly. Though not, it must be said, as badly as the Pakistani security establishment, whose strategically critical support, passive and active, for the insurgents was apparently not fully understood by US military planners until only very recently.

There are now thousands of books on this most recent Afghan conflict, ranging from airport thrillers to specialist study. Many books are extremely good, some are very bad. Little America is powerful and important and should be read by anyone interested in this ongoing and deeply depressing war, particularly those waiting for helicopters or eating Hot Tamales in Bagram.