By Frank Gardner
BBC security correspondent
Tony Blair's 10 years in power will be remembered not just for Iraq, but for his close personal involvement in counter-terrorism.
Mr Blair said the world changed on 11 September 2001
After the attacks on New York and Washington the world learned a new phrase: the controversial "War on Terror" had begun.
On 11 September 2001 the world, said Mr Blair, had changed. Terrorism was everybody's problem and it needed to be confronted, he said.
One of Britain's first responses to the 9/11 attacks was to send troops into Afghanistan, helping to pursue Al-Qaeda as it fled its bases and training camps. That global organisation initially lost its physical base, but the terrorist threat to Britain did not go away.
In February 2003, just one month before the US-led invasion of Iraq, Blair ordered the Army to deploy to Heathrow after intelligence warnings of a plot to shoot down an airliner.
Neither a weapon nor any plotters were ever found, prompting some to suspect it was just a stunt to build support for the coming invasion of Iraq.
Lord Carlyle, who is the independent reviewer of terrorism legislation, believes that British public confidence in the intelligence and security agencies was badly undermined by mistakes made over Iraq.
He said: "Progress has been hampered in counter-terrorism by the Iraq dossier which has very little to do with this area but which has undoubtedly affected trust.
"It has been hampered by some over-hasty legislation, (particularly the Belmarsh provisions) and it's been hampered by what I would describe as the cortege of home secretaries when one consistent home secretary would have been a better idea".
At home, faced with foreign terror suspects who could be neither tried nor deported, the Blair government introduced control orders, which were both unpopular and often ineffective.
When it came to incitement to acts of terrorism, the government was slow to recognise and react to the threat from extremist preachers like Abdullah Al-Faisal who was openly encouraging his followers to murder non-Muslims.
The authorities hesitated for years before finally arresting and charging Abu Hamza, the radical preacher of Finsbury Park Mosque, whom many Muslims complained besmirched the name of their religion with his violent view of the world.
The strikes on Afghanistan were among the first response to 9/11
As the perception grew throughout the early 2000s of Britain becoming a terrorist target for Al-Qaeda and its sympathisers, the government steadily built up resources for the overstretched intelligence services.
MI5, the security service, which reports to the home secretary, embarked on a recruitment drive to double its headcount and take on large numbers of new young intelligence officers with second languages.
Belatedly, MI5 has expanded beyond its London headquarters and now has 8 regional offices around the country to try to gain what it calls a "rich picture" of potential terrorist activity, although this has, in turn, led many British Muslims to fear they are unfairly under suspicion.
That resentment, already simmering over the number of police stop-and-searches of Asian-looking men on the streets, grew after the London bombings of 7 July 2005.
For the counter-terrorist community this was everyone's nightmare. They had always feared that one day Britain might face an undetected cell of suicide bombers, but they expected them to come from abroad in the classic Al-Qaeda tradition.
Instead, 7/7, as the bombings became known, were the work of British citizens, almost certainly trained in camps in Pakistan.
After the bombings Al-Qaeda tried to make life as awkward as possible for Tony Blair by referring to them as "just retribution" for British military actions in Iraq and Afghanistan.
Downing Street pointed out that the attacks of 9/11 had taken place before there was a single British soldier in either of those countries.
The London bombings were followed by false alarms. First, there was the mistaken shooting by police at Stockwell station of Jean-Charles de Menezes, a harmless Brazilian electrician; the police initially said his shooting was linked to the investigation into 7/7.
Then came a huge police raid on an address in Forest Gate that found nothing, but resulted in the shooting and wounding of a terror suspect who was later released.
British Muslim trust in the government and the police reached an all-time low, despite various successes in thwarting plots to blow up targets in Britain.
Many British Muslims, already wary of the police, critical of foreign policy in the Middle East, and outraged by the injustice of Guantanamo Bay, became convinced they were being victimised.
Human rights campaigners like Shami Chakrabati of Liberty now worry that counter-terrorist measures could be backfiring.
She said: "All this tough talk and draconian legislation is leaving us less free but I think it's leaving us a lot less safe as well.
The Forest Gate raid angered many Muslims
"I think that we are undermining our entry in the competition of ideas by flirting with torture. By interning people without trial we are seeming, at times, to be hypocritical about these democratic values that we want to see promoted."
And still the threats keep coming. The alleged plot to blow up a string of transatlantic airliners last summer was, according to the authorities, a sign that Al-Qaeda and its affiliates have not given up their grand plans and that Britain is firmly in their sights; those arrested say they are innocent.
This year in March, the Home Office announced it was splitting in two to allow the home secretary to concentrate more on counter-terrorism.
The plan had the blessing of Tony Blair but critics sniped that the clearest sign of a failing policy was when the bureaucracy was reshuffled.
The truth is that overall, the government is having considerable success in intercepting terrorist plots. But it is almost certainly losing the long-term battle to steer potential recruits away from violence.
For all too many people in Britain, Tony Blair is intimately linked to Iraq and for the 1,600 known terrorist suspects in the UK that makes his government 'the enemy'.
It will take at least a year to determine if changing the occupants of Number 10 Downing Street will make any difference to that view.