WASHINGTON—A complaint about potentially harassing emails sent by a woman romantically linked to Central Intelligence Agency chief David Petraeus to a second woman sparked the security investigation that led Mr. Petraeus to suddenly resign on Friday, according to people familiar with the investigation.

U.S. officials familiar with the probe said the Federal Bureau of Investigation began its investigation following a complaint from a woman in Florida about Paula Broadwell, Mr. Petraeus's biographer and the woman identified...