The official Saudi Press Agency, quoting the head of the Interior Ministry's prison's department, said 20 inmates and three prison guards suffered smoke inhalation.
The fire broke out at al-Haer prison at about midday Monday and was brought under control after about three hours.
A security official said initial reports suggest an electrical short-circuit may have started the blaze.
Saudi Interior Minister Prince Nayef ordered an investigation into the fire's cause, the Saudi news agency said.
Riyadh has two prisons for men and one for women.