A magistrate's court in Embu County has acquitted 13 Ethiopians who were facing charges of being in the country illegally.
The foreigners, who include two minors, have been in remand for close to six months.
Senior Principal Magistrate Henry Nyakweba ruled that they should instead be processed to get refugee status.
"All the accused persons be handed over to the refuge affairs secretariat in Nairobi forthwith to have their status determined and thereafter hey be processed as will be found legally appropriate in accordance within the law," he ruled.
Nyakweba said asylum seekers should not be arrested and charged in court before due process is followed at the Refuges Appeals Board.
He said he freed the 13 after the prosecution failed to prove its case against them.
In September last year, the Ethiopians wept in court as they appealed to the magistrate to protect them and help them get asylum status as they had fled from their war-torn country for their own safety.
They had all denied the offence of unlawfully being in Kenya.
Although an interview to establish the status of the immigrants indicated that they were not asylum seekers but were seeking employment, the court observed they could not be repatriated to the country that is facing civil war.
Their lawyer Faisak Hussein Swale said they were happy that the immigrants had gotten justice through the courts.
"The ruling sets a precedence in dealing with the number of Ethiopians escaping their country due to the ongoing civil war," Swale said.