In 1780, Luigi Galvani discovered that when two different metals (e.g., copper and zinc) are in contact and then both are touched at the same time to two different parts of a muscle of a frog leg, to close the circuit, the frogs leg contracts. He called this "animal electricity".  The frogs leg, as well as being a detector of electrical current, was also the electrolyte (to use the language of modern chemistry).
A year after Galvani published his work (1790), Alessandro Volta showed that the frog was not necessary, using instead a force-based detector and brine-soaked paper (as electrolyte). (Earlier Volta had established the law of capacitance  with force-based detectors).  In 1799 Volta invented the voltaic pile, which is a stack of galvanic cells each consisting of a metal disk, an electrolyte layer, and a disk of a different metal. He built it entirely out of non-biological material to challenge Galvanis (and the later experimenter Leopoldo Nobili)s animal electricity theory in favor of his own metal-metal contact electricity theory. Carlo Matteucci in his turn constructed a battery entirely out of biological material in answer to Volta.  Voltas contact electricity view characterized each electrode with a number that we would now call the work function of the electrode.  This view ignored the chemical reactions at the electrode-electrolyte interfaces, which include H formation on the more noble metal in Voltas pile.
Although Volta did not understand the operation of the battery or the galvanic cell, these discoveries paved the way for electrical batteries; Volta's cell was named an IEEE Milestone in 1999.
Some forty years later, Faraday (see Faraday's laws of electrolysis) showed that the galvanic cell—now often called a voltaic cell—was chemical in nature.  Faraday introduced new terminology to the language of chemistry: electrode (cathode and anode), electrolyte, and ion (cation and anion).  Thus Galvani incorrectly thought the source of electricity (or source of electromotive force (emf), or seat of emf) was in the animal, Volta incorrectly thought it was in the physical properties of the isolated electrodes, but Faraday correctly identified the source of emf as the chemical reactions at the two electrode-electrolyte interfaces. The authoritative work on the intellectual history of the voltaic cell remains that by Ostwald.
It was suggested by Wilhelm König in 1940 that the object known as the Baghdad battery might represent galvanic cell technology from ancient Parthia.  Replicas filled with citric acid or grape juice have been shown to produce a voltage.  However, it is far from certain that this was its purpose—other scholars have pointed out that it is very similar to vessels known to have been used for storing parchment scrolls.