THE NAME "jack-o'-lantern" is of British origin and dates from the 17th century, when it literally meant "man with a lantern" (i.e., a night watchman). It was also a nickname for the natural phenomenon known as ignis fatuus (fool's fire) or "will o' the wisp," the mysterious, flickering lights sometimes seen at night over wetlands and associated in folklore with fairies and ghosts playing pranks on travelers.
Over time "jack-o'-lantern" became the popular term for a homemade object also known as a "turnip lantern," defined by Thomas Darlington in his 1887 volume The Folk-Speech of South Cheshire as "a lantern made by scooping out the inside of a turnip, carving the shell into a rude representation of the human face, and placing a lighted candle inside it."
According to legend, the jack-o'-lantern took its name from a roguish Irishman known as Stingy Jack, who tricked the Devil into promising he wouldn't end up going to hell for his sins. When Jack died he found out he had been barred from heaven, too, so he journeyed down to the gates of hell to demand his due.
Wouldn't you know it, the Devil kept his promise by dooming Jack to wander the earth for all eternity with only an ember of hellfire of to light his way. Thenceforth, the legend says, he was known as Jack O' Lantern.