The mystery man was held by armed police near the specially strengthened gates at the back of the Prime Minister's house.

Moments earlier, Gordon Brown had left No 10 for a farewell party at Westminster for Tony Blair. The gates at the rear entrance in Horseguards Road are always locked with armed police on permanent guard. But the back of No10 and No11 are partly visible from the road and nearby St James's Park.

Last night detectives were quizzing the man, who was believed to have a replica gun, at a Central London police station.

A Met spokesman said a policeman had spotted the firearm in the man's car in Horseguards Road.

The spokesman added: "It was an imitation weapon. There was no security breach."

Britain is on a heightened state of alert with the threat of a terror attack considered to be "highly likely".

The scare came 24 hours after Osama bin Laden's No 2, Ayman al-Zawahri, warned that al-Qaeda will attack Britain again for awarding a knighthood to Salman Rushdie.

But last night's incident, which followed attempted al-Qaeda bombings in London and Glasgow, is not thought to be linked to terrorism.