A boy in a school uniform blew himself up at a Pakistani army recruitment centre in the troubled northwest region on Thursday, killing 20 cadets, military and security officials said.
The attack challenged official assertions that army offensives had weakened al Qaeda-linked Taliban militants waging a campaign to destabilise Pakistan's US-backed government.
The brazen bombing suggested militants are regrouping after a lull in major attacks. Militant operations in recent months have been mostly sectarian and have not focused on military targets.
"The bomber struck recruits when cadets were busy in their morning training," a military official told Reuters. At least 20 people were wounded.
The boy apparently walked into the compound, officials said.
Prime Minister Yusuf Raza Gilani condemned the attack at the Punjab Regiment Centre in the town of Mardan.
"Such cowardly attacks cannot affect the morale of the security agencies and the resolve of the nation to eradicate terrorism," he said in a statement.
Gilani's government is under pressure on several fronts. It is trying to revive a stagnant economy and public discontent is growing over official corruption, rampant poverty and power cuts.
The United States, which provides billions of dollars in aid, wants Pakistan to step up its fight against militant groups who cross the border to attack Western forces in Afghanistan.
But Pakistan's military is already stretched fighting homegrown militants.