The bomber blew himself up when a security guard stopped him outside the National Database and Registration Authority (Nadra) office that regulates government databases and manages the sensitive registration database of Pakistan citizens in Mardan town of Khyber-Pakhtunkhwa, officials said.
"If the attacker had not been stopped by a security guard at the office's gate, the death toll would be significantly higher," Mardan police Deputy Inspector General Saeed Wazir was quoted as saying by the BBC Urdu.
He said the bomber was between 22-25 age group.
An emergency rescue officer said at least 22 people were killed in the suicide blast at a time the office was crowded.
Also Read
Human body parts were seen strewn across the blast site.
The injured, several of them critical, were shifted to Mardan Medical Complex and other hospitals in the city, where a state of emergency has been declared.
The area has been cordoned off as rescue and security officials rushed to the site. Interior Ministry has sought an immediate report on the blast.
The Nadra office, charged with the establishment of a new registration system for the entire population of Pakistan, most of the time remains crowded.
Prime Minister Nawaz Sharif strongly condemned the attack and expressed deep grief over loss of innocent lives.
Tehreek-i-Taliban Pakistan splinter group Jamaat-ul-Ahrar claimed responsibility for today's attack, saying it carried out the attack on "heathen Pakistan state".
The bombing is one of the deadliest since a security crackdown following the Peshawar school massacre last year that saw 150 people, mostly students, killed by the Taliban.