Inmates at the Shimo La tewa Prison in Mombasa County. [File, Standard]

Prisoners and detainees have the right to attend the funerals of close family members, the High Court has ruled.

Justice Lawrence Mugambi said they have a right to be treated humanely, but warned that there were circumstances that could lead to the application being denied.

"A declaration be and is hereby issued that all sentenced prisoners and pretrial detainees held in custody have the right to be treated humanely which right includes permitting them to attend funeral and burials of their close family member unless there are compelling reasons for declining granting of permission," Mugambi ruled.

The ruling came from a petition filed by ex-journalist Moses Dola Otieno, who was charged with the murder of his wife, Wambui Kabiru.

Judge Mugambi ordered Interior CS Kithure Kindiki to put in place mechanisms and structures to allow for the temporary release of prisoners.

Attorney General Justin Muturi and CS Kindiki opposed the petition, arguing that the prison was small and allowing it would only overburden it.

The judge said the right was not absolute and the authorities had to take certain considerations into account before granting the request.

These include whether there is a budget to facilitate the prisoner, the presence of the prisoner's victims and the safety of the public.