At the stroke of dusk on October 31, ghosts, goblins and grin-filled children take to the night in the United States and beyond. But how did this holiday of tricks and treats begin, and how did it become a fixture even at the White House? Here is a spooky stroll through the history of Halloween, in spirit and in substance.

Ancient Roots, Ghostly Beginnings

The story of Halloween begins more than two millennia ago with the Celts and their festival of Samhain. The Celts, who lived across what is now Ireland, northern France and the British Isles, observed the end of the harvest season at the start of November, a liminal time when the boundary between the living and the dead was believed to blur, according to History.com.

On the night before the new Celtic year, people kindled sacred fires, sacrificed crops or livestock, and donned animal skins or masks to confuse wandering spirits, according to History.com. In their minds, the dead might walk the earth, and supernatural forces were near.

With the spread of the Roman Empire, elements of Roman festivals merged into the tradition. The Roman feast Feralia, commemorating the dead, and a festival honoring Pomona, the goddess of fruit and trees, may have been stitched into the fabric of Samhain, perhaps a root of apple bobbing, History.com adds.

As Christianity expanded across Europe, the church sought ways to absorb pagan traditions. In the 7th and 8th centuries, a holiday honoring saints (All Saints’ or All Hallows) was moved to November 1. The evening before became All Hallows’ Eve, eventually shortened to Halloween, per History.com, and over time, All Souls’ Day, November 2, was added to commemorate the dead, further entwining Christian and older customs.

Halloween Comes to America

Early American observances of Halloween were modest, especially in Puritan New England, where festivities were discouraged. More common were rural harvest parties, storytelling and community gatherings in other colonies. By the mid-19th century, the influx of Irish immigrants escaping the Irish Potato Famine brought renewed energy to Halloween traditions in the United States.

In the late 1800s and early 1900s, Halloween became more secular and community oriented. Newspapers and civic groups urged that frightening or gruesome elements be toned down, and transformed the holiday into a more child-friendly affair, notes History.com. Home and school costume parties became a favorite. Trick-or-treating took shape. Children dressed up and went door to door asking for food or money, a descendant of European “souling” and begging traditions.

Over the 20th century, Halloween became ever more commercial. Costumes, candy, decorations, haunted houses and media tie-ins transformed it into one of America’s major holidays.

Halloween at the White House

While Halloween’s roots stretch back centuries, the White House itself only joined the fun in the mid-20th century, according to Whitehousehistory.org.

The first known White House decoration occurred in 1958 under First Lady Mamie Eisenhower. She adorned the Executive Mansion with skeletons, jack-o’lanterns and stalks of dried corn, and hosted a luncheon for the wives of staff members in the State Dining Room. Historians note that since then, first families, especially those with young children or grandchildren, have embraced Halloween festivities.

During John and Jackie Kennedy’s administration, trick-or-treat events for staff and friends were introduced, and photographs began to document the children in costume in the Oval Office. As time passed, larger public Halloween events were held on the grounds of the White House.

From Bonfires to Candy Corn

The Halloween of today still carries echoes of its ancient past, but with candy rather than sacrifices, and parties instead of bonfires. Jack-o’lanterns derive from an Irish myth of Stingy Jack, originally carved from turnips. In America, pumpkins proved a better canvas, according to History.com. Because the Roman or Christian influence introduced traditions like “souling” or All Hallows, many of our modern customs are hybrids.

Today, Halloween is thoroughly secular and celebratory. Kids and adults don costumes of every kind. Trick-or-treating is a beloved ritual. Haunted houses and spooky decorations proliferate. The holiday melds ancient superstition, Christian tradition and modern commerce.

And in Washington D.C., the ghosts and goblins are officially invited to the White House each year, where presidents, first ladies, staff and children all mix in the magic of Halloween’s long and twisting history.