The Jack-o'-lantern tradition is linked to an old folktale from Ireland about a man named Stingy Jack and his dealing with the Devil. There are numerous variations of the Irish tale, but they all end the same.
Stingy Jack was a wicked prankster and an old drunk who enjoyed playing tricks on everyone and anyone including his family, friends and even the Devil himself. One dark night, Jack was drinking in a local public house and there he met the Devil. Jack invited the Devil to have a drink with him.
Not wanting to use his own money to pay for the drinks, Jack convinced the Devil to turn himself into a coin to cover the cost— in exchange for Jack's soul. The Devil agreed and transformed himself, but instead of paying for the drinks, Jack slipped the coin into his pocket next to a silver cross he always carried. The cross prevented the Devil from changing back into his original form. Jack would only free the Devil under the condition that he would not bother Jack for one year and that, should Jack die in that year, the Devil would not claim his soul. The Devil agreed and Jack let him free.
The year passed and Jack, while out walking on a country road, found the Devil waiting for him. The Devil said he had come for Jack's soul. But Jack convinced the Devil to climb into a nearby apple tree and pick Jack the choicest apple before taking his soul. The Devil agreed and while he was up in the tree, Jack carved the sign of the cross into the tree's bark. The Devil could not climb out of the tree. Jack would not remove the sign until the Devil promised not to bother him for 10 years and that, should Jack die in that time, the Devil would not claim his soul. The Devil grudgingly agreed and Jack let him free.
Soon after, Jack did die. But when he went to heaven, God barred him from entering because of his wicked ways so Jack journeyed down to the gates of hell.
But the Devil remembered Jack's trickery, kept his promise not to claim Jack's soul and would not allow Jack into hell. Instead he sent Jack away into the darkness with only an ember of hellfire to light his way. Jack carved out a turnip to carry the ember and is doomed to wander the earth for all eternity.
The Irish referred to Jack's ghost as "Jack of the Lantern," which over time became "Jack-o'-lantern." In Ireland and Scotland, people carved their version of Jack's lantern out of turnips or potatoes. In England, large beets were used. The lanterns were carved with scary faces and placed into windows or near doors to frighten away Stingy Jack's ghost and other wandering evil spirits. In the 1800s, large numbers of Irish immigrated to North America. They found pumpkins, a common native fruit, bigger and softer to carve than turnips or potatoes, so pumpkins became the new Jack-o'-lanterns at Halloween.