A Pakistani army official says government troops have killed 18 militants who attacked a military checkpoint near the Afghan border .