When you think about it, scooping the innards out of a large squash, carving a scary face into it, and jamming a candle inside is a bit weird. But so is the story behind the first jack-o’-lantern. As far back as the 1500s, Irish storytellers regaled about a blacksmith named Stingy Jack, who invited the Devil to the bar. When their night of carousing ended, Jack needed cash and the Devil, handily, transformed himself into a coin so Jack could pay the tab. Ever the trickster, Jack pocketed the coin and used a cross to prevent Satan from changing back. He later let the Devil loose under the condition that his soul would never go to hell.

But there was a problem. When Jack died, God wouldn’t let him into Heaven, so his soul was stuck on Earth. Feeling bad that his old buddy would be wandering the world in the dark, the Devil gave Jack a lump of burning coal that Jack, for reasons untold, placed in a carved-out turnip. Thus: jack-o’-lantern.

The tale was devised to explain will-o’-the-wisps, the mysterious flashes of light created by flaming gas around swamps and bogs, and it became tradition for the Irish to carve turnips, beets, and potatoes to trick friends into thinking Stingy Jack was lurking nearby. Immigrants took the custom to the U.S, where the plentiful pumpkin became the veggie of choice.

This story originally appeared in the September 2014 issue of mental_floss magazine. Subscribe to our print edition here, and our iPad edition here.