More than 90 were wounded. Most of the victims appeared to members of the opposition Pakistan People's Party, formerly headed by the slain Benazir Bhutto, said Mushtaq Hussain, an administrative official in the volatile tribal region bordering Afghanistan where the attack took place.
He said a suicide bomber apparently "rammed his explosive-laden car into the election office."
Interior Minister Hamid Nawaz said 27 people were killed and more than 90 wounded.
"Several of our party members are lying in a pool of blood," said Zafar Ali, a party supporter at the scene.
The attack in Parachinar, an area bordering Afghanistan, came two days before parliamentary elections considered crucial to restoring democracy in Pakistan after eight years of military rule under President Pervez Musharraf.
Monday's elections will take place against a backdrop of rising Islamic militancy throughout Pakistan, and many candidates have been discouraged from holding large rallies. Security fears are highest in lawless tribal areas along the Afghan border.