After a hesitant start, America’s war on terrorism and its military campaign in Afghanistan have proved the sceptics wrong with some remarkable successes. But much remains to be done, and much could still go wrong