An explosion and a gun battle killed five people in a southern Kazakh city on Saturday, following a threat by Islamist militants to carry out attacks in the oil-producing state that was long seen as the most peaceful in Central Asia.

A recent series of blasts and shootouts, including one claimed by Islamist militants, has unnerved the authorities and public of the former Soviet republic, a mainly Muslim nation of nearly 17 million.

A local resident of the city of Taraz told Reuters that he heard the sound the of explosions and gunfire in the centre of the city, about 550 km (350 miles) west of Almaty, Kazakhstan's financial centre and biggest city.

We never thought that this kind of thing could happen here, said the resident, who did not want to be identified. He said many people had been wounded and that the city centre had been cordoned off.

Kazakhstan's Interior Ministry said in a statement that an unidentified man had raided an arms store in Taraz on Saturday morning, killing a security guard before escaping in a car with two Saiga semi-automatic rifles.

Two policemen were killed during a subsequent pursuit, before the assailant blew himself up outside a store in the city centre, killing one more traffic policeman, the ministry said in the statement. It did not identify the assailant.

Earlier reports by local news agencies had said at least one blast had occurred outside the building of the National Security Committee, the successor to the Soviet-era KGB.

Interfax news agency cited its correspondent at the scene as saying he had seen police removing a body in a black bag.

MILITANT THREAT

Kazakhstan, Central Asia's largest and most successful economy, had until this year not witnessed the outbursts of Islamist militancy seen in other parts of the former Soviet region that lies north of Afghanistan.

Authorities officially ruled out any link to Islamist militancy when a man blew himself up in May at the offices of the National Security Committee in the northwestern city of Aktobe, killing only himself.

But after other unexplained shootouts and bombings, followed by the arrest of 18 people in the oil-hub city of Atyrau in August on suspicion of planning acts of terror, Kazakhstan adopted a new religion law last month.

President Nursultan Nazarbayev, who has ruled Kazakhstan as a secular republic since independence from the Soviet Union in 1991, has backed the law -- which bans prayer rooms in state buildings -- as a means of stamping out religious extremism.

Jund al-Khilafah (Soldiers of the Caliphate), a hitherto unknown militant group, threatened violence in a video message shortly before claiming responsibility for two blasts in Atyrau on October 31. The suspected bomber was killed.

The prosecutor-general's office said this week that the group was responsible for the Atyrau blasts and had linked up with a militant cell formed in 2009 to carry out the bombings.

The prosecutor's office said on November 9 that the Kazakh nationals who founded the group were hiding on the border between Afghanistan and Pakistan.

(Reporting by Robin Paxton, Dmitry Solovyov and Maria Gordeyeva; Editing by Rosalind Russell)