The history of electromagnetic theory begins with ancient measures to understand atmospheric electricity, in particular lightning. People then had little understanding of electricity, and were unable to explain the phenomena. Scientific understanding into the nature of electricity grew throughout the eighteenth and nineteenth centuries through the work of researchers such as Ampère, Coulomb, Faraday and Maxwell.
In the 19th century it had become clear that electricity and magnetism were related, and their theories were unified: wherever charges are in motion electric current results, and magnetism is due to electric current. The source for electric field is electric charge, whereas that for magnetic field is electric current (charges in motion).
The knowledge of static electricity dates back to the earliest civilizations, but for millennia it remained merely an interesting and mystifying phenomenon, without a theory to explain its behavior and often confused with magnetism. The ancients were acquainted with rather curious properties possessed by two minerals, amber (Greek: ἤλεκτρον, ēlektron) and magnetic iron ore (μαγνῆτις λίθος magnētis lithos, "the Magnesian stone, lodestone"). Amber, when rubbed, attracts lightweight objects, such as feathers; magnetic iron ore has the power of attracting iron.
Based on his find of an Olmec hematite artifact in Central America, the American astronomer John Carlson has suggested that "the Olmec may have discovered and used the geomagnetic lodestone compass earlier than 1000 BC". If true, this "predates the Chinese discovery of the geomagnetic lodestone compass by more than a millennium". Carlson speculates that the Olmecs may have used similar artifacts as a directional device for astrological or geomantic purposes, or to orient their temples, the dwellings of the living or the interments of the dead. The earliest Chinese literature reference to magnetism lies in a 4th-century BC book called Book of the Devil Valley Master (鬼谷子): "The lodestone makes iron come or it attracts it."