A federal appeals court ruled that San Francisco illegally strip-searched thousands of jail inmates.

The court says the city violated the constitutional rights of jail inmates when it subjected them to visual body cavity searches without having any reason to believe they were carrying weapons or contraband.

The 2-1 decision by the Ninth U.S. Circuit Court of Appeals in San Francisco applies to a city policy that was in effect from April 2002 to January 2004.

City officials had argued that the strip searches were necessary to keep inmates from smuggling guns and drugs into jail.

San Francisco changed the policy in January 2004 after a lower-court judge ruled that it was unconstitutional.