The attacker detonated a hand grenade before exploding his suicide vest among the morning crowds at the main gate of Mardan district courts.
"First there was a small blast followed by a big blast," chief rescue officer in Mardan Haris Habib said.
"So far we have recovered 12 bodies of lawyers, police personnel and civilians. Besides this, we rescued 52 injured, including lawyers, police personnel and civilians from the spot," Habib was quoted as saying by the Express Tribune.
This was second attack on Pakistan's legal community. Last month, a blast in southern Balochistan province capital Quetta killed more than 70 people, nearly wiping out the senior lawyers of the city.
More From This Section
Today's attack on court occurred hours after four heavily-armed suicide attackers tried to storm a Christian colony in Peshawar, killing one person and wounding several others before being gunned down by security forces.
In the predawn attack in the same province, terrorists struck the colony near Warsak Dam, just north of Peshawar, and killed one Christian security guard.
Five persons including two Frontier Corps personnel, one policeman and two civilian guards were injured in the attack.
Director General Inter-Services Public Relations Lt-Gen Asim Bajwa tweeted that all four terrorists have been killed.
"Terrorist attacked Christian Colony Warsak Road, Peshawar. Security forces promptly responded. All 4 suicide bombers killed. Search in progress," Bajwa tweeted.
Two of the attackers detonated their suicide jackets while two others were killed by security forces.
No outfit has claimed responsibility for the attack, but such attacks are blamed on the Taliban.
Taliban militants stormed an army-run school in Peshawar in December 2014, killing more than 150 people, mostly children, in Pakistan's one of the worst terror attacks.
Today's attacks came a day after an army spokesman said that Pakistan had destroyed organised presence of militants on its soil.
The army had launched operation 'Zarb-e-Azb' in June 2014 in a bid to flush out militants from the country's restive tribal areas and bring an end to the militancy that has killed thousands of civilian since 2004.