For adults, annual costume parties are a big hit in late October, but for children, Halloween often means just one thing: trick or treating. Most of us have memories of dressing up and getting candy on Halloween night, but how did this holiday tradition come to be? Read this short history of trick or treating to find out!

Like many holiday traditions, the roots of trick or treating are ancient. The modern custom developed over thousands of years and is the result of several cultural practices slowly morphing together.

Trick or treating has its earliest origins in the ancient Celtic festival of Samhain, for which villagers dressed in animal skin costumes on October 31st and left out offerings of food to placate the wandering spirits of the dead. Eventually, people began dressing up as these spirits and performing antics in exchange for treats of food and drink.

Later, when Roman Catholicism had spread over much of Europe, All Soul’s Day—celebrated on November 2nd—took on many of the characteristics of the older Samhain festival. On this day, the poor would go around asking for treats in exchange for praying for dead relatives.

Yet another predecessor of modern trick or treating is Guy Fawkes Night, celebrated in early November, when children would dress in masks and go out begging for pennies.

What we know as trick or treating today slowly developed as immigration to the United States increased and different cultures with various holiday traditions mixed to eventually produce the Halloween tradition children love so much today.