The suicide bomber blew himself up inside the district court's compound in Shabqadar Bazaar of Charsadda district in Khyber-Pakhtunkhwa.
At least 14 people, including two policemen, were killed while 26 others were wounded in the attack, District Police Officer Sohail Khalid said.
The Jamatul Ahrar, a splinter group of the banned Tehrik-i-Taliban Pakistan (TTP), claimed responsibility for the attack, saying that it was carried out to avenge the hanging of Mumtaz Qadri, killer of Taseer.
Security and emergency teams reached the blast site and sealed the area. A probe was immediately launched into the assault.
More From This Section
Shabqadar tehsil is close to Mohmand tribal region, which is one of seven semi-autonomous tribal regions in the northwest, where Pakistani Taliban and al-Qaeda-linked militants were said to have carved out strongholds.
Shabqadar is some 30 kilometres west of Charsadda, where militants attacked a university on January 20 in an attack that left 21 people, mostly students, dead.
At the time of the explosion, the courts were crowded after a break over the weekend.
Qadri, deputed on the security of Taseer, had killed the governor at a market close to the latter's house in 2011 in Islamabad for allegedly criticising the controversial blasphemy laws and was convicted the same year.
Qadri's execution triggered protests by thousands of Islamists who called it a "black day".
Taseer, who died aged 66, had termed the blasphemy regulations, introduced by Pakistan's military ruler Zia-ul-Haq in 1980s, as "black laws" drawing the ire of extremists.