Opium comes from a kind of poppy flower. It evolved around 100 million years ago in West Asia and Central Asia. People probably realized as soon as they got to West Asia, about 60,000 years ago, that you could use opium as a medicine. By 6000 BC, in the Stone Age, West Asian farmers were already growing opium in their fields. So opium is one of the earliest domesticated crops.
After the flower dies, a spherical seed pod forms under the flower. (You can see the same thing on roses.) If you make a cut in the seed pod, some goo oozes out. That’s the opium. The plant produces this alkaloid for the same reason that other plants produce other alkaloids like nicotine, caffeine, cocaine, or quinine. It may be to make the plant taste bad to insects who might attack it. Or, possibly, it’s to get bees addicted so they’ll come back often and spread the plant’s pollen.
In Bronze Age Greece about 1500 BC, paintings of poppy flowers on vases show that people were using opium at least as far west as Greece. In New Kingdom Egypt, doctors prescribed opium for infant colic. Greek doctors prescribed opium for pain, to stop bleeding, and to cause vomiting (to “clean you out”).
By around 500 BC, doctors had brought opium as far north-west as Scandinavia and Britain, where Roman soldiers used opium in the 100s AD. Galen recommended opium to calm the cough of tuberculosis. By the time of the Islamic Empire, about 900 AD, the doctor Al Razi was using opium as an anesthetic so his patients wouldn’t feel the pain of surgical operations.
Muslims arriving in India about 1000 AD brought opium there; Indian medical books from 1200 AD discuss the use of opium to control diarrhea (which works fine). Around the same time, traders along the Silk Road brought the first opium to China. The rulers of China soon made opium illegal there, fearing this foreign medicine.
Meanwhile, people in northern Europe also stopped using opium, thinking of it as un-Christian because Islamic doctors recommended it. As a result, European people had no working anaesthetic to use for operations, and no way to deal with pain except alcohol. The rapid spread of distilled alcoholic drinks like brandy and whiskey in the 1300s might be related to this need. On the other hand, by the 1500s people were growing opium in India. Probably Indian traders had brought opium to East Africa too.
Learn by doing: go find some poppies to look at
More about opium: the Opium Wars