Residents of Kamae at Kahawa West, Nairobi, on Wednesday stoned and chased away police officers who had gone to arrest 23 Ethiopians from their hideout.
The residents, who were angered by the killing of a boda boda rider on Tuesday night by people who had posed as passengers, accused the police of working with criminals.
They pelted the officers with stones and threatened to lynch the foreigners, whom they accused of committing crimes.
It took the intervention of anti-riot officers to quell the chaos.
The residents said the presence of the foreigners was linked to human trafficking, which they accused the police of abetting.
“We believe the police around here are aware of this (trafficking) business. These foreigners could be engaging in crime and that is why we want them out,” said a resident, who declined to be named.
Kiambu County Police Commander James Mugera said demonstrations over the killing of the boda boda rider and the theft of his motorcycle began in the morning.
“As residents joined boda boda riders in demonstrations, they were met with the news that a hideout for foreigners had been discovered and this angered them even more,” he said.
Mr Mugera said the officers had to call for reinforcements to save the Ethiopians. Police had to shoot in the air and use tear gas to disperse the mob.
Residents stormed the house where the foreigners were found, looted and destroyed property.
“The foreigners arrived on Tuesday night. Some have no identification documents and others cannot communicate in English or Kiswahili,” Mr Mugera said.
They will be charged with being in the country illegally as police search for the owner of the house.
Cases of foreigners in the country illegally are on the rise, an indication that the trafficking of mostly Ethiopians and Somalis, is taking root in Kenya.
Last month, nine Ethiopians were arrested at Miaseyi in Voi on the Mombasa-Nairobi highway on their way to Mombasa.