Pumpkin carving has become such a cherished tradition that the sight of the glowing, orange-faced grimaces every October is more heartening than frightening. But the original Jack-o-Lanterns were meant to ward off unwanted visitors—and one look at them in museums tells you they probably worked.

IrishCentral tells the origin story:

A man called Stingy Jack invited the devil for a drink and convinced him to shape-shift into a coin to pay with. When the devil obliged, Jack decided he wanted the coin for other purposes, and kept it in his pocket beside a small, silver cross to prevent it from turning back into the devil.

Jack eventually freed the devil under the condition that he wouldn't bother Jack for one year, and wouldn't claim Jack's soul once he died. The next year, Jack tricked the devil once more by convincing him to climb up a tree to fetch a piece of fruit. When he was up in the tree, Jack carved a cross into the trunk so the devil couldn't come down until he swore he wouldn't bother Stingy Jack for another ten years.

When Jack died, God wouldn't allow him into heaven and the devil wouldn't allow him into hell. He was instead sent into the eternal night, with a burning coal inside a carved-out turnip to light his way. He's been roaming the earth ever since. The Irish began to refer to this spooky figure as "Jack of the Lantern," which then became "Jack O'Lantern."

This legend is why people in Ireland and Scotland began to make their own versions of Jack's lantern by carving grotesque faces into turnips, mangelwurzels, potatoes and beets, placing them by their homes to frighten away Stingy Jack and other wandering evil spirits and travelers.

When the Irish and Scots emigrated to America, bringing the tradition along, they found that pumpkins, native to America, made perfect fruits for carving. Pumpkin Jack-o-Lanterns have been an integral part of Halloween festivities ever since.