Pakistani officials say armed tribesmen have killed more than 40 foreign militants in the latest fighting along Pakistan 's western border with Afghanistan .