Halloween has its roots in an ancient Celtic festival called Samhain, which was celebrated around October 31, when the veil between earthly humans and the supernatural world was believed to thin. Celts believed this connection with the otherworld meant the dead could return, but dangerous spirits could, too. They wore costumes to protect themselves from malevolent forces that crossed over, so they could blend in with spirits, monsters, fairies, and demons, and thus escape harm.
When Christianity spread to the British Isles, people began to reframe pagan traditions. Between the fifth and 11th centuries, November 1 was observed as a celebration of saints and martyrs, dubbed All Saints’ Day, and the following day, All Souls’ Day, commemorated the dead. Celebrations, which involved large bonfires and costumes, looked a lot like Samhain. During these festivals — collectively known as “Hallowtide” — less-fortunate people would go “souling” door to door, reciting rhymes and asking the wealthy for pastries called “soul cakes” in exchange for prayers for their loved ones.
References to this kind of practice date back to the 14th century, and while the tradition died out in Protestant areas, it survived in Catholic communities. In Ireland and Scotland during the 18th and 19th centuries, children went “guising” — they’d dress up in costumes and perform tricks, such as singing songs or telling jokes, in exchange for treats. When Irish and Scottish people immigrated to North America, they brought those traditions with them. The term “trick or treat” originated in the 1920s in the Canadian provinces of Saskatchewan and Alberta, and eventually made its way to the United States by the end of the decade.