A Taliban suicide bomber has killed 30 people at the funeral of a policeman in Pakistan, including five senior police officers.

A Reuters reporter at the scene in the western city of Quetta described chaos as injured police struggled to carry bloodstained colleagues into ambulances.

"They are not Muslims. They are not humans," Inspector General Mushtaq Sukhera said.

"We have no other option but to fight against terrorists," he added.

"We have made sacrifices and we will continue to do so and we will not bow down."

The local provincial chief secretary said 21 of the 30 people killed were police officers and 62 others were wounded.

Children attending the funeral were also among those kiled.

Fayyaz Sumbal, the deputy inspector general of operations for Quetta, was among those killed.

The Taliban has claimed responsibility.

A Taliban spokesman said the attack was carried out in revenge for the arrest and mistreatment of their fighters.

Quetta, the provincial capital of Baluchistan, is home to many militants, including the Taliban, sectarian groups and separatist fighters.

The explosion, at a supposedly secure location in one of Pakistan's most heavily militarised cities, again called into question the ability of the security services to defend themselves and curb the escalating insurgency.

The Quetta attack was captured live on television as cameras broadcast mourners and journalists scrambling away from the mosque.

Weeping policemen wandered among the blood and body parts, looking for colleagues, or sat in shock amid abandoned shoes and other belongings.

The suicide bomber was wearing a jacket packed with ball bearings and shrapnel, a member of the bomb squad said.

The bomber had tried to enter the mosque where senior officers lined up to offer prayers for their colleague, who was gunned down earlier today.

But he was stopped by police and detonated his explosives just outside the mosque, several witnesses said.

It was not yet clear how the bomber had passed through several other layers of tight security.

Pakistan has been hit by a wave of attacks since the government of Prime Minister Nawaz Sharif came to power after a May election.