A suicide bomber blew himself up in a court in north-western Pakistan on Monday, killing eight people and injuring more than 15.

The bomber blew himself up inside the district court compound in Shabqadar Bazaar of Charsadda district.

Police said the attacker was intercepted but managed to sneak inside the court house and detonated the explosive device.

"The suicide bomber was trying to enter the judicial complex and he blew himself up when the police stopped him," Saeed Wazir, a police officer, told Pakistan's Express Tribune newspaper.

A policeman was among those killed in the explosion that rocked the packed court room. Television footage showed heavily damaged court room and premises, with charred remains of vehicles lying around in the compound.

"We were sitting with a lawyer when a huge explosion took place in the sessions court," another police officer said.

The army has thrown a security cordon around the scene, while the police said the casualties may rise.