LONDON — The British military can deploy a surface-to-air missile battery atop an apartment building during the Olympics, a judge said Tuesday, throwing out a challenge by residents who argued that their home would become a prime target for terrorists.

The battery would be capable of launching warheads toward suspicious aircraft at up to three times the speed of sound.

The government is planning to set up six such installations around London as part of a massive security operation for the Summer Games that will also include 13,500 troops, more than Britain has stationed in Afghanistan.

Tenants of the Fred Wigg Tower apartment high-rise in East London, near the Olympic Park, took the government to court, saying that it failed to consult them properly in deciding to plunk down an anti-aircraft missile battery on their rooftop and alleging that their right to a peaceful home life had been violated.

High Court Justice Charles Haddon-Cave dismissed that challenge Tuesday, saying the military was within its rights to choose a residential building as a missile-launching platform and that its outreach efforts to the community, while not obligatory, were “immaculate.”

Residents of the apartment building were laboring under “something of a misapprehension” as to the nature of the weaponry and of the risks posed by it, Haddon-Cave was quoted as saying.

Critics have described the government’s security arrangements for the Summer Olympics, which kick off July 27, as overkill. In addition to the missiles, the military also is mooring its biggest warship in the Thames and patrolling the skies with spy planes and helicopters with snipers.

The security budget for the Games now stands at about $875 million, double the originally intended amount.