Mexican federal agents and army troops fanned out across this besieged border city Tuesday to replace 500 police officers, the latest move by the government to purge the troubled force of corrupt and incompetent cops.

Last week, 21 officers, including two deputy chiefs, were detained on suspicion of having ties to drug traffickers and flown to Mexico City for questioning by Mexico's anti-organized-crime unit.

The moves come as authorities struggle to control a brutal war among rival traffickers that has killed more than 300 people in Tijuana since late September and left residents wary of large swaths of the city.

Despite past purges, the 2,200-member police department is still viewed by many as an arm of the drug cartels.

Officers have been accused of working as lookouts, informants, hit men or bodyguards for drug smugglers, and scores of them have been killed over the years.

The 500 officers who were replaced will be sent to a police academy for training and background checks and could return in a few months, authorities said.

Their removal appears to be aimed at weakening Teodoro Garcia Simental, known as El Teo, a suspected crime boss who is believed to control the police in the city's east.

Federal agents and troops, supported by Baja California state police, will patrol four neighborhoods considered Garcia's strongholds, including La Mesa and Cerro Colorado.

Tijuana Mayor Jorge Ramos hailed the replacements as part of his long-term efforts to reform the unruly department. Earlier this year, 100 officers suspected of corruption were fired.

Prosecutors also said Tuesday that a top police official who was Mexico's main liaison with Interpol was under house arrest as part of an investigation into leaks to drug cartels.

Interpol said officials in Ricardo Gutierrez Vargas' position would have access to information on suspects, the Associated Press reported.

Among the 21 officers detained in Tijuana last week was a veteran policeman well known in U.S. law enforcement circles. Javier Cardenas, the Mexican liaison to U.S. federal and local agencies, was highly regarded for capturing fugitives and suspects here and turning them over to U.S. authorities.

He was taken into custody by a convoy of soldiers that descended on the downtown police headquarters.

Marosi is a Times staff writer.

richard.marosi@latimes.com