Britain is girding itself for the biggest peacetime security operation in its history featuring anti-aircraft missiles on rooftops and a warship in the River Thames for the London Olympics.

A security force of more than 40,000 military and civilian personnel, backed by a huge intelligence operation, will turn the British capital into a fortress to protect venues, athletes and millions of visitors.

The £553-million ($877-million, 662-million-euro) operation will watch for a range of scenarios, from "lone wolf" terror strike to cyber-attacks, protests, riots, transport breakdowns and even extreme weather.

Security has already been tight around the Olympic torch as it has made its way around the United Kingdom in the past month. The only incident of note has been a protest as it went through Northern Ireland.

Britain's Defence Secretary Philip Hammond announced that Rapier surface-to-air missiles would be deployed across the capital to guard against 9/11-style attacks, despite opposition from residents.

The missiles -- Rapier and smaller high-velocity systems -- will be deployed at six sites including on the rooftops of blocks of flats in east London near the Olympic Park.

Hammond said recently a major nine-day military exercise codenamed Exercise Olympic Guardian that took place in May had "achieved its objectives".

The exercise simulated a terror attack and included the huge helicopter carrier HMS Ocean taking up station near Greenwich, while Royal Air Force fighter planes were deployed near London at RAF Northolt for the first time since World War II.

During the Games themselves, the centrepiece of the 40,000-strong security force will be a contingent of 13,500 military personnel from the Army, Royal Navy and Royal Air Force.

The deployment is substantially larger than the entire British mission in Afghanistan, currently at around 9,500 personnel.

There will also be around 12,500 police officers deployed daily -- making it the country's largest ever pre-planned policing operation -- and more than 16,000 private security guards and unpaid volunteers.

MI5, Britain's domestic intelligence service, has reportedly suspended all leave to ensure it has its full complement of some 3,800 staff for the Olympics, double the number it had after 9/11.

British officials say up to 500,000 athletes, coaches, security staff and media and tourism visa applicants from more than 200 competing nations are being screened by the intelligence services ahead of the Olympics.

Meanwhile the military will take charge of London's airspace for the first time since World War II. Civilian controllers will take operational responsibility but will be under overall supervision of the defence ministry.

It is expected to create a zone of secure airspace which is restricted by the military, and will work out of a military-civilian control centre in Hampshire, southeast England, The Times reported.

Security has been a fundamental question for the London Games from the start.

The day after London was named host city on July 6, 2005, four homegrown suicide bombers attacked three underground trains and a bus, killing 52 people.

It is also 40 years since Palestinian militants massacred Israeli athletes at the 1972 Munich Olympics, and 16 years after a bombing at the Atlanta Olympics.

"It's impossible to totally guarantee that you can get rid of all risk. You can't," security analyst Margaret Gilmore of the Royal United Services Institute in London told AFP.

"But you can go a long way to deterring anyone who wants to disrupt or attack the Games, and mitigating any impact if, for example, a terrorist attack gets through."