A grocery chain pulled Tylenol from store shelves in 24 states today as a "precautionary measure" after authorities said a 23-year-old New York woman who had taken the pain-relieving drug died of cyanide poisoning.

A&P Food Stores ordered the removal from all of its more than 1,000 stores, spokesman Michael Rourke said, "as a precautionary measure . . . pending the outcome of an investigation" by Yonkers police.

Westchester County officials tonight banned the sale of Extra-Strength Tylenol capsules throughout the county and asked consumers to bring in any containers purchased in the past two months.

The dead woman was identified as Diane Elsroth, of Peekskill, N.Y. Police Commissioner Joseph Fernandes said she died Saturday morning at the home of a friend in Yonkers.

Clare Palermo, an aide to Westchester County Executive Andrew P. O'Rourke, said Ellsworth had taken two capsules from a 24-capsule bottle of Extra-Strength Tylenol believed to have been purchased at an A&P in nearby Bronxville.

During an autopsy, examiners detected cyanide in the woman's blood. Three of the capsules remaining in the Tylenol bottle were suspected to contain the poison, Palermo said.

The Food and Drug Administration, in a statement from Washington, said it was joining the investigation, and advised residents in the Yonkers area to avoid taking Tylenol capsules "until more is known. As a special precaution, the FDA further advises consumers to avoid code ADF916, expiration 587. The lot has been in distribution since August 1985 . . . . "

The statement noted that "in the past, such instances have invariably proved local in nature."

Johnson & Johnson set up a toll-free number for consumers -- 800-237-9800.

Seven people died in the Chicago area between Sept. 29 and Oct. 1, 1982, after taking cyanide-tainted Extra-Strength Tylenol.

The victims were a 12-year-old girl, a newlywed couple and a relative, a flight attendant and two suburban women.

No one was arrested in the incidents, which prompted a nationwide temporary withdrawal of the medication by its manufacturer, Johnson & Johnson, as well as several copycat incidents.

In the wake of the deaths, drug companies redesigned their containers to make them more resistant to tampering.

Last night, Jim Murray, a spokesman for Johnson & Johnson in New Brunswick, N.J., said company officials were trying to get more information from New York police before deciding what to do.

In the Chicago killings, two men were charged in related crimes. James Lewis of Kansas City was charged with extortion of Johnson & Johnson, and Roger Arnold of Chicago was charged in the shooting death of a man that prosecutors said he mistakenly believed had implicated him.