One Kenyan student has died and 141 others have suffered injuries in a stampede on the campus of the University of Nairobi when students mistook several accidental explosions for an attack, according to an official.

The victim in Sunday's stampede was identified as a male third-year student, according to the Associated Press news agency, which cited Peter Mbithi, the vice chancellor of the University of Nairobi.

The injured students have been taken to hospitals for treatment, Mbithi said.

He said an electrical transformer exploded and students thought it was an attack like the April 2 assault by Somalia's al-Shabab rebels on Kenya's Garissa University College in which 148 people were killed.

"It was around 5am local time and the transformer at the campus exploded about four or five times which made students mistake it for an attack," said Mbithi. "Most of them jumped out of their hostels thinking it was an al-Shabab attack."

Sharon Mutual, a student of the university, told the Reuters news agency: "Some students rushed through the doors, others jumped through the window from the fifth floor, others on the fourth floor. Most of them were unconscious after falling." 

Al-Shabab has killed more than 400 people on Kenyan soil in the past two years, including 67 during a siege at Nairobi's Westgate mall in 2013, damaging tourism and inward investment.

Kenya responded to the latest attack with air strikes on al-Shabab targets in Somalia and closure of informal financial firms suspected of involvement in the funding of the rebels.

It has also said the UN refugee agency should relocate hundreds of thousands of Somali refugees sheltering in the Dadaab camp in the remote northeastern region.

Source: Agencies