AS AMERICA prepares to mark the tenth anniversary of the attacks on the twin towers and the Pentagon, the events of September 11th 2001 are still shaping history. The country's fightback against al-Qaeda this past decade has been both relentless and, in many ways, successful. Even before its SEALs killed Osama bin Laden in May, America had eviscerated his organisation. Hundreds of its people have been captured and killed and many of its most dangerous plots thwarted. Its new second-in-command was killed just last month. Leon Panetta, a former director of the CIA and now defence secretary, gave a needless hostage to fortune when he said during a recent visit to Afghanistan that America was within reach of inflicting a “strategic defeat” on al-Qaeda. The organisation still has a dangerous presence in Yemen, among other places. But after a decade of intelligence-gathering, counter-attacks and defensive measures, America does seem a good deal less vulnerable than it was on September 10th ten years ago.

The damage he did

That said, an Osama bin Laden conducting a posthumous review of the past decade would have cause to feel satisfied. Although he did not create the caliphate he dreamed of, one of his main declared aims was to draw America into “bleeding wars” in the Muslim lands, and in this he most cruelly succeeded. But for September 11th, America would not have invaded Afghanistan or Iraq, where some 6,000 of its soldiers, and many of its allies' soldiers, have lost their lives in grinding wars of attrition. The costs-of-war project at Brown University thinks that on a “very conservative” estimate about 137,000 civilians have been killed in Afghanistan, Iraq and Pakistan and that the wars have created more than 7.8m refugees in these countries. The Brown project puts the wars' ultimate cost, including interest payments and veterans' care, to the United States at up to $4 trillion—equivalent to the country's cumulative budget deficits for the six years from 2005 to 2010.

America has precious little to show for this sacrifice apart from the disruption of al-Qaeda. Iraq is in better shape than looked possible at the height of the sectarian slaughter that engulfed it soon after the American invasion. But on a single day recently al-Qaeda was able to launch 42 attacks across the country. And when the last American troops depart at the end of this year, they will leave behind a country that is neither a close friend (the government of Nuri al-Maliki looks more readily to Iran) nor a full democracy. It is true that when America toppled Saddam Hussein it rid Iraq of dictatorship, not just a dictator. The country's new rulers say that they are democrats, and Iraq has held elections galore. But its politicians have yet to show a proper respect for the rights of minorities or a willingness to let the people vote them out of office.

The democratic ideal has lately found its way to the Arab world from another direction, by way of the Arab spring. In so far as this marks a repudiation of al-Qaeda's doctrine, it should eventually be good for the West as well as for the Arabs—provided the jihadists do not hijack the democratic spring when autumn sets in. But the West cannot claim the credit for this awakening. It was certainly not inspired by the invasion of Iraq (which this newspaper, wrongly certain that Saddam possessed weapons of mass destruction, strongly supported). Most Arabs opposed the invasion, dismissed Iraq's new government as a puppet and resented George Bush's “freedom agenda”. People's power did not stir in Tunisia, Egypt and the wider Arab world until almost a decade later, and then it was because of the eruption of long-simmering local frustrations, not because of America's display of “shock and awe” in Mesopotamia.

As for Afghanistan, America has for the present achieved its principal aims of chasing out al-Qaeda and overthrowing its Taliban protectors. When al-Qaeda and the Taliban established a new haven over the border in Pakistan, the CIA's drones took the fight to them there as well. But the Taliban insurgency in Afghanistan smoulders on, and it remains an open question how long the feckless administration the West props up in Kabul will survive NATO's planned departure in 2014.

Meanwhile the price of pushing al-Qaeda to the brink of strategic defeat has been to create a new danger. By pursuing the jihadists into Pakistan, America has helped to destabilise a paranoid, nuclear-armed country of 190m Muslims. America is not solely to blame for this: Pakistan has played an exasperating double game, accepting American money with one hand while abetting assorted jihadists with the other. Its spies may well have known where bin Laden was hiding, which is why Mr Obama sent in the SEALs without permission or warning. Since the raid, relations have darkened. But even before it, far more Pakistanis saw America as an enemy than as a partner. America's homeland may be safer than it was ten years ago, but its strategic posture has deteriorated in a swathe of the Middle East and South Asia, and will worsen further if Iraq falls under the spell of the mullahs' Iran, or Pakistan implodes.

Messing with the mind of Islam

Al-Qaeda has not just poisoned relations between countries. It has poisoned minds as well. In all of the Muslim countries polled recently by the Pew Global Attitudes Project, majorities still refuse to believe that the perpetrators of September 11th were Arabs. Pew finds that the Muslim world and the West still see the other as fanatical and violent. Muslims are liable to add that Westerners are also immoral and greedy—and largely to blame for keeping Muslims poor. An American-made peace in Palestine might have assuaged some bitter hearts, but Mr Bush never pushed for peace hard enough, and, for all his fine speeches, Mr Obama's inept diplomacy ended in humiliation. A poll for the Arab American Institute reported this summer that America's standing across the Arab world is now lower than it was at the end of Mr Bush's term.

The poison has reached the home front too. Some Americans hoped, after British Muslims set off bombs on London's Underground in 2005, that home-grown jihadism would be confined to “Eurabia”. They were wrong. Although polls show that the great majority of Muslims in America are loyal citizens, less likely than other religious groups to express support for bloody attacks on civilians, a few violent hearts will always heed the call of jihad. In 2009 an American Muslim gunned down his fellow soldiers at Fort Hood in Texas and last year a new immigrant from Pakistan tried to set off a car bomb in New York's Times Square.

These and other plots, some directly organised and some merely inspired by al-Qaeda, have fed, and fed on, a growing intolerance in the host societies. After September 11th Mr Bush was careful to stress that America was not fighting Islam, “a religion of peace”. Today's Republicans have been less responsible. Newt Gingrich, now running for president, joined a reckless campaign to stop the construction of an Islamic centre and mosque in lower Manhattan. Many other Republicans have echoed his ludicrous claim that Islamic sharia law is infiltrating America's legal system. In parts of Europe relations are much worse. It was fear of an Islamic takeover that appears to have prompted Anders Behring Breivik's murder of 77 of his fellow countrymen in Norway in July.

Stretching the West

Immediately after September 11th, most of its allies expressed their solidarity with the United States. And yet the past decade has nibbled away at the cohesion of the West. The purpose of NATO had already been called into question before September 11th, after the collapse of the Soviet Union. At first, the felling of the twin towers gave the alliance a new lease on life. Invoking collective defence, NATO joined the war in Afghanistan. Special friends of the superpower, such as Britain, and those that wanted to become special friends, such as Poland and Ukraine, volunteered for duty in Iraq as well. But for most public opinion in Europe the war in Iraq was always a stretch too far, and a decade of body bags has blunted the European appetite for expeditionary warfare at America's side.

NATO has survived the test of Afghanistan, and just passed a new one in Libya, but both tests exposed big weaknesses. The alliance's European members keep some 2m men in uniform but struggled to send between 25,000 and 40,000 to Afghanistan. Only 11 weeks into the fight against Muammar Qaddafi, they had run short of munitions and needed American help. America's own performance in Libya was a study in caution. Europeans are tired of being sucked into what many see as America's wars; America is exasperated by a Europe that does not pull its weight.

The exhaustion of the Western alliance has coincided with the growing buoyancy and assertiveness of Asia and Latin America. Asia's economic renaissance was under way before September 11th, but fighting al-Qaeda was a draining distraction that made this inevitable rebalancing of world power look starker. Mr Bush once asked Hu Jintao what kept him awake at night. Creating 25m new jobs a year, was the Chinese president's answer. Mr Bush's own chief worry was another terrorist attack. To secure the homeland, America did not just wage foreign wars. It also created a colossal security and intelligence bureaucracy at home. The Washington Post reported last year that more than 1,200 government organisations and almost 2,000 companies were working on programmes related to counter-terrorism, homeland security and intelligence.

Some might say that America has paid a big price in the loss of freedoms great and small. It has become normal to remove your shoes before boarding an aircraft. America did not intern Muslim citizens after September 11th, as it did Japanese-Americans after Pearl Harbour, but the Bush administration rode roughshod over cherished liberties. Congress, the courts and a new president eventually pushed back, but not all the way. Though America no longer subjects suspected terrorists to waterboarding, Guantánamo is still open, an emblem of everything America is supposed not to stand for. Many of its inmates could spend the rest of their lives in captivity without ever having a proper trial.

Moving on

As September 11th fades into the history books (see article), America has started to move on. The burning towers, the battle on the slopes of Tora Bora, the pyrotechnics over Baghdad, the sadistic pictures of hooded prisoners in Abu Ghraib: these have come to seem like photographs in an album, vividly remembered but no longer part of today's reality. In New York a new tower is taking shape at Ground Zero (see article). A host of different problems now plague America. The financial collapse of 2008 and the recession that followed have had a more direct impact than terrorism on the lives of ordinary people. The 2012 election will focus less on the thing once called “the global war on terror” and more on gridlock in Washington, lost jobs, soaring spending and towering debt. The world-bestriding hyperpower of ten years ago has lost its self-confidence and craves a chance to regroup. At the Ames straw poll in the Iowa heartland last month, Ron Paul, a Republican presidential candidate, was cheered to the rafters when he called for the troops to come home.

Americans are eager to cut their losses after a wretched decade and turn from nation-building abroad to nation-building at home. This instinct to move on is an admirable reflex that has jerked America out of the doldrums many times before. But moving on should not mean turning inward or dropping its guard. The whole world will be the poorer if an exhausted America concludes that it can never again intervene to rescue helpless civilians from a murderous dictator—even if, as in Libya, the superpower sometimes “leads from behind”.

Besides, al-Qaeda and its imitators are still dangerous. Its thwarted plots have included blowing up ten airliners simultaneously over the Atlantic. It has sewn explosives into its bombers' shoes and underwear, and disguised bombs as printer cartridges. Its arm in Yemen is said to be exploring the use of ricin in new attacks. Although most Muslims have rejected its fantastic aims and bloody methods, a terrorist outfit does not need to convert large numbers in order to cause chaos. Only 19 men mounted the history-altering attacks of ten years ago.

The United States is better prepared today. All the same, future danger cannot be averted simply by declaring victory (or accepting defeat) and retreating behind a Great Wall of America. The superpower made mistakes galore after September 11th, of which the invasion of Iraq was probably the biggest. It will face new security challenges in the coming decade, such as responding with fewer resources to a rising China. And yet those who say blithely that it overreacted to the attacks of September 11th will never know how much more devastation the jihadists might have wrought if America had not pursued them into the mountains of Afghanistan and Pakistan, shredding their networks and forcing them into hiding. The trick in the next ten years will be to win back the trust of allies (especially Pakistan), use force more sparingly, go wherever possible with the grain of Muslim sentiment instead of rubbing against it. But there can be no return to the innocence of September 10th 2001—and, sadly, no end to the vigilance.