A military official accused the Pakistani Taliban of staging the attack, which took place near a courthouse in Islamabad.