At least eight students have been killed and 10 others taken to hospital after a fire broke out at a girls' school in the Kenyan capital, Nairobi.

The blaze, which broke out early on Saturday, burned down one dormitory of Moi Girls school.

"We were sleeping and a girl woke us up and said that our hostel was burning. We were helped to safety by some teachers," Daniella Maina, a shaken 16-year-old schoolgirl, told Reuters news agency.

The Kenyan police did not immediately respond to a request for comment.

"A fire broke out at the school at 2:00am in the morning in one of the dormitories. It is very, very sad," said Fred Matiangi, the education minister.

"This is a school that's got 1,183 students and, as you know, is one of our top schools in the country and a school that we are very proud of."

Matiangi said it was too early to know what caused the fire and investigations were under way.

"We have 10 students who have been admitted to hospital right now, two of them with serious injuries. We have taken a decision this morning to close the school for two weeks because we want to conduct thorough investigations on what happened," Matiangi added.

A statement from his office on Saturday evening said the death toll had risen from seven to eight.

The incident has brought back memories of the deaths of 67 students in a dormitory fire at a high school in eastern Kenya in March 2001.

It later emerged the fire was caused by students apparently angered by the school's administration.

Last year, at least 126 high schools experienced arson attacks in what appeared to be protests by students over the shortening of holidays and limiting of visits by parents.

Matiangi took those measures after widespread cheating in 2015 high school final-year exams.