Police have arrested 23 Ethiopians who were found hiding in a house at Kamae in Kahawa West, Nairobi.
The police had to shoot in the air to save the foreigners from being lynched by angry residents, who accused them of being criminals.
The residents claimed the foreigners were involved in the killing of a boda boda operator, who was shot dead on Tuesday night.
Residents also accused the police of abetting crime in the area.
Anti-riot police were called in to assist the regular police, who were pelted with stones by the residents.
The residents also chased away the regular police, claiming they were working with criminals.
According to Githurai Deputy County Commissioner Kennedy Changandu, the Ethiopians were taken into police custody and would be charged in court for being in the country illegally.
"One of the boda boda operators was killed and the residents were accusing [the Ethiopians] of being involved," he added.
Police are now hunting for the tenant and the owner of the house.
Some of the residents vandalised the three-bedroom house, carting away property including a TV set, a water meter, and a gate that they brought down. They also unsuccessfully attempted to burn down the house.
One of the immigrants said they arrived only the previous night aboard a bus and their passports were confiscated by a Kenyan who was hosting them, adding that they had been promised jobs locally.