PESHAWAR, Pakistan — A suicide bomber struck a regional branch of Pakistan’s National Database and Registration Authority in Mardan on Tuesday, killing at least 22 people and wounding more than 40, a police official said.

The bomber, riding a motorcycle, had tried to force his way through the authority’s main gate and detonated his explosives after being stopped by a guard, said Haroon Bacha, the deputy superintendent of police in Mardan.

“The office was closed for a lunch break, and when the bomber tried to force his way inside, the guard stopped him, a scuffle ensued and there was an explosion,” he said. “The brave man tried to stop the bomber and lost his life.”

Saeed Wazir, a regional police officer, said that the bomber appeared to be in his early to mid-20s, and that he was wearing a suicide vest laden with about 20 pounds of explosives.