The Opium poppy has been cultivated and utilized throughout human history for a variety of medicinal (analgesic, anti-tussive and anti-diarrheal) and hypnotic properties linked to the diversity of its active components, which include morphine, codeine and papaverine.

The name codeine is derived from the Greek word kodeia (κώδεια) for "poppy head".

Until the beginning of the 19th century, raw opium was used in diverse preparations known as laudanum (with alcohol) and paregoric elixirs, a number of which were popular in England since the beginning of the 18th century; the original preparation seems to have been discovered in the Netherlands around 1715 by a chemist named Lemort; in 1721 the London Pharmocopeia mentions an Elixir Asthmaticum, replaced by the term Elixir Paregoricum ("pain soother") in 1746.

Codeine was first isolated in 1832 by M. Robiquet, a French chemist and pharmacist while working on refined morphine extraction processes. This paved the way for the elaboration of a new generation of safer, codeine-based specific antitussive and antidiarrheal formulations, which in addition to the pain killing properties are still the main applications for the drug today. Codeine is widely used in combination with other substances, for specific maladies. In some countries, cough syrups and tablets containing codeine are available without prescription; some potential recreational users are reported to buy codeine from multiple pharmacies so as not to arouse suspicion. In the UK there is a cut-off level for the amount of codeine in any tablet that can be purchased over the counter (OTC). Some users, particularly people who seek to hide their dependence will visit multiple pharmacies regularly to obtain suppliers without arousing suspicion.