According to Irish folklore a man named Jack, well known for his drunkenness and quick temper got very drunk at a local pub on All Hallows Eve. He met the Devil outside the pub because the Devil wanted his soul. Jack asked him one more drink but he didn't have the money to pay .
So the Devil took the shape of a coin and Jack put it into his wallet that had a cross-shaped catch. Jack agreed to free the Devil under one condition: he should let him live for another year. The Devil accepted.
The following year the Devil reappeared and asked Jack to accompany him. Jack told the Devil to take an apple from a tree; when the Devil climbed up, Jack carved a cross on the tree and the Devil was trapped again. This time Jack asked the Devil ten more years of life in exchange for his freedom: again the Devil had to accept.
Unfortunately Jack died almost a year later. In paradise he was not accepted. In hell, the Devil recognized him and refused him admission; but, since he wasn't so bad, he gave Jack a piece of coal to help him find his way in the dark of limbo. Jack put the piece of coal into a turnip and it became known as "Lack O'Lantern". On All Hallows Eve you can still see Jack's flame burning as he searches for a home.
The Irish used to carve turnips or beets as lanterns and use them on Halloween night as festival lights. When they emigrated to the USA, they brought their traditions with them: they couldn't find turnips in America but they found a lot of pumpkins which were suitable substitutes to make a Jack O'Lantern; since then, pumpkins are an essential part of Halloween celebrations.