NAIROBI (Reuters) - A rogue officer who "went berserk" was responsible for an attack on a police station in western Kenya on Thursday in which seven people died, a police spokesman said.

Police had previously blamed the attack on a suspected recruiter for Somali militant group al Shabaab, who they said grabbed a gun from a guard while under arrest.

"The gunman ... turned out to be a local police officer who for yet unknown reasons, went berserk and grabbed a firearm," spokesman George Kinoti said in a statement late on Thursday.

The officer shot and killed six policemen before taking prisoners hostage at Kapenguria police station, officials said.

He was later shot dead by an elite police squad flown in from Nairobi. Local newspapers said a seventh officer, a member of the rescue team, was also killed.

Kinoti said police had opened an inquiry into the incident.

(Reporting by George Obulutsa; Editing by Edmund Blair and John Stonestreet)