late 14c., "a medicine," from Old French farmacie "a purgative" (13c.), from Medieval Latin pharmacia, from Greek pharmakeia "use of drugs, medicines, potions, or spells; poisoning, witchcraft; remedy, cure," from pharmakeus (fem. pharmakis) "preparer of drugs, poisoner, sorcerer" from pharmakon "drug, poison, philter, charm, spell, enchantment." Beekes writes that the original meaning cannot be clearly established, and "The word is clearly Pre-Greek."
Meaning "use or administration of drugs" is attested from c. 1400; that of "place where drugs are prepared and dispensed" is first recorded 1833. The ph- was restored 16c. in French, 17c. in English (see ph).