Impure pyridine was undoubtedly prepared by early alchemists by heating animal bones and other organic matter, but the earliest documented reference is attributed to the Scottish scientist Thomas Anderson. In 1849, Anderson examined the contents of the oil obtained through high-temperature heating of animal bones. Among other substances, he separated from the oil a colorless liquid with unpleasant odor, from which he isolated pure pyridine two years later. He described it as highly soluble in water, readily soluble in concentrated acids and salts upon heating, and only slightly soluble in oils.
Owing to its flammability, Anderson named the new substance pyridine, after  (pyr) meaning fire. The suffix idine was added in compliance with the chemical nomenclature, as in toluidine, to indicate a cyclic compound containing a nitrogen atom.
The chemical structure of pyridine was determined decades after its discovery. Wilhelm Körner (1869) and James Dewar (1871) suggested that, in analogy between quinoline and naphthalene, the structure of pyridine is derived from benzene by substituting one C–H unit with a nitrogen atom. The suggestion by Körner and Dewar was later confirmed in an experiment where pyridine was reduced to piperidine with sodium in ethanol. In 1876, William Ramsay combined acetylene and hydrogen cyanide into pyridine in a red-hot iron-tube furnace. This was the first synthesis of a heteroaromatic compound.
The first major synthesis of pyridine derivatives was described in 1881 by Arthur Rudolf Hantzsch. The Hantzsch pyridine synthesis typically uses a 2:1:1 mixture of a β-keto acid (often acetoacetate), an aldehyde (often formaldehyde), and ammonia or its salt as the nitrogen donor. First, a double hydrogenated pyridine is obtained, which is then oxidized to the corresponding pyridine derivative. Emil Knoevenagel showed that asymmetrically substituted pyridine derivatives can be produced with this process.
The contemporary methods of pyridine production had a low yield, and the increasing demand for the new compound urged to search for more efficient routes. A breakthrough came in 1924 when the Russian chemist Aleksei Chichibabin invented a pyridine synthesis reaction, which was based on inexpensive reagents. This method is still used for the industrial production of pyridine.