Gunmen wearing military uniforms and wielding assault rifles and grenades attacked Pakistan’s army headquarters today, sparking a ferocious gun battle outside the capital that killed four of the assailants and at least six soldiers, authorities said.