The term “jack-o’-lantern” was first applied to people, not pumpkins. The term meant a man with a lantern, or a night watchman. As time progressed it began to be used to refer to the mysterious lights sometimes seen at night.

These lights—called jack-o’-lanterns were created when gases from decomposing plant matter ignite as they come into contact with electricity or heat. For centuries people told stories to explain the mysterious lights. In Ireland, dating as far back as the 1500s, those stories frequently revolved around a man named Jack.

Stingy Jack invited the devil to join him for a drink. He did not want to pay for the drinks, and convinced the devil to turn himself into a coin that could be used to settle the tab. The devil did so, but Jack skipped out on the bill and kept the devil-coin in his pocket with a silver cross so that the devil couldn’t shift back to his original form. Jack eventually let the devil loose but made him promise that he wouldn’t seek revenge on Jack, and wouldn’t claim his soul when he died.

Jack irked the devil again by convincing him to climb up a tree to pick some fruit, then carved a cross in the trunk so that the devil couldn’t climb back down. Jack freed him again, on the condition that the devil once again not take revenge and not claim Jack’s soul.

Stingy Jack eventually died and God would not allow him into heaven, and the devil, keeping his word, rejected Jack’s soul at the gates of hell. Instead, the devil gave him a single burning coal to light his way and sent him off into the night to “find his own hell.” Jack put the coal into a carved-out turnip and has supposedly been roaming the earth with it ever since. In Ireland, the ghost lights seen in the swamps were said to be Jack’s improvised lantern moving about as his restless soul wandered the countryside. He and the lights were dubbed “Jack of the Lantern,” or “Jack O’Lantern.”

The legend came to the new world with the Irish, and it collided with other old world traditions and a popular crop. Making vegetable lanterns was a tradition of the British Isles, turnips, beets, and potatoes were lit with coal, wood embers, or candles to celebrate the fall harvest. Kids would sometimes wander off the road with a glowing veggie to trick their friends or travelers into thinking they were a lost soul. In America, pumpkins were easy to come by and excellent for carving, thus were absorbed into the old tradition. Kids refined the prank and began carving crude faces into the pumpkins and make the lanterns look like disembodied heads. By the mid-1800s, Stingy Jack’s nickname was applied to the prank pumpkin lanterns and the pumpkin jack-o’-lantern got its name.

Toward the end of the 19th century, jack-o’-lanterns went from just a trick to a standard seasonal decoration.