A federal appeals court has upheld the constitutionality of random bag searches by police in America's busiest subway system to prevent terrorism.

The 2nd U.S. Circuit Court of Appeals on Friday rejected a challenge to the searches by the New York Civil Liberties Union, saying that a lower court judge properly concluded that the program put in place in July 2005 was "reasonably effective."

The searches began after deadly terrorist bombings in London's subway system. The NYCLU filed a lawsuit to stop them, saying they were an unprecedented intrusion on privacy and ineffective because they can be easily evaded.

• Click here to visit FOXNews.com's Homeland Security Center.

The appeals court said it was proper for Judge Richard M. Berman to conclude that preventing a terrorist attack on the subway was important enough to subject subway riders to random searches.

Berman had concluded that the searches were a reasonably effective deterrent and that the intrusion on the privacy rights of riders was minimal.

In its written ruling, the appeals court noted that New York's subway system is an "icon of the city's culture and history, an engine of its colossal economy, a subterranean repository of its art and music, and, most often, the place where millions of diverse New Yorkers and visitors stand elbow to elbow as they traverse the metropolis."

The court noted that New York's subway system, the nation's largest, includes 26 interconnected train lines and 468 far-flung passenger stations, carrying 4.7 million passengers on an average weekday and 1.4 billion riders a year.

The opinion said it was "unsurprising and undisputed that terrorists view it as a prime target."

The appeals court also noted that the subway system was targeted for attack at least twice in the last nine years. Those attacks, thwarted by police, including a bomb plot in 1997 in Brooklyn and a 2004 plot to bomb the Herald Square subway station.