PESHAWAR, Pakistan — The top American spy in Pakistan left the country on Thursday amid threats to his life after his name was revealed in a lawsuit over alleged American drone attacks, United States intelligence officials said Friday.

The C.I.A. station chief in Islamabad is perhaps the agency’s most important undercover assignment overseas because that person oversees its secret war in Pakistan using armed drones that target Al Qaeda and the Taliban.

The suit that named the C.I.A. station chief, who was working undercover and whose name is classified, was filed over attacks that killed at least two Pakistanis.

The breach of security comes as attacks attributed to American drones in Pakistan’s lawless tribal areas continued to intensify, with three strikes on Friday killing 26 militants.

The threats against the station chief “were of such a serious nature that it would be imprudent not to act,” according to one American intelligence official who spoke on condition of anonymity.

C.I.A. spokesman George Little would not confirm that the station chief had to leave Pakistan, but did say that “station chiefs routinely encounter major risk as they work to keep America safe,” and that “their security is obviously a top priority for the C.I.A., especially when there’s an imminent threat.”