You might guess it’s a custom dreamed up by a modern-day, real-life Willy Wonka, but people have been chewing gum, in various forms, since ancient times. There’s evidence that some northern Europeans were chewing birch bark tar 9,000 years ago, possibly for enjoyment as well as such medicinal purposes as relieving toothaches. The ancient Maya chewed a substance called chicle, derived from the sapodilla tree, as a way to quench thirst or fight hunger, according to “Chicle: The Chewing Gum of the Americas” by Jennifer P. Mathews. The Aztecs also used chicle and even had rules about its social acceptability. Only kids and single women were allowed to chew it in public, notes Mathews. Married women and widows could chew it privately to freshen their breath, while men could chew it in secret to clean their teeth.

In North America, the Indians chewed spruce tree resin, a practice that continued with the European settlers who followed. In the late 1840s, John Curtis developed the first commercial spruce tree gum by boiling resin then cutting it into strips that were coated in cornstarch to prevent them from sticking together. By the early 1850s, Curtis had constructed the world’s first chewing gum factory, in Portland, Maine. As it turned out, though, spruce resin was less-than-ideal for producing gum because it didn’t taste great and became brittle when chewed. Curtis and others who’d jumped into the gum business after him subsequently switched to ingredients such as paraffin wax.

The next key development came when an inventor in New York, Thomas Adams, got his hands on some chicle through exiled Mexican president Antonio Lopez de Santa Anna. The exact details of how the two men connected are unclear, although they would’ve been in contact following Santa Anna’s arrival in the United States sometime after the mid-1850s (before that, he led Mexican forces at the Battle of the Alamo in 1836 and served multiple terms as Mexico’s president). Santa Anna wanted assistance developing chicle into a substitute for rubber, and believed the riches he stood to earn would enable him to return to power in his homeland. Adams began experimenting with chicle but when his work failed to yield the desired results, Santa Anna abandoned the project. Adams eventually realized that rather than trying to create a rubber alternative, he could use chicle to produce a better type of chewing gum. He formed a company that by the late-1880s was making gum sold across the country, according to Mathews. Chicle, imported to the United States from Mexico and Central America, served as the main ingredient in chewing gum until most manufacturers replaced it with synthetic ingredients by the mid-1900s.

In the 20th century, chewing gum made William Wrigley Jr. one of the wealthiest men in America. Wrigley started out as a soap salesman in his native Philadelphia. After moving to Chicago in 1891, he began offering store owners incentives to stock his products, such as free cans of baking powder with every order. When the baking powder proved a bigger hit than the soap, Wrigley sold that instead, and added in free packs of chewing gum as a promotion. In 1893, he launched two new gum brands, Juicy Fruit and Wrigley’s Spearmint. Because the chewing gum field had grown crowded with competitors, Wrigley decided he’d make his products stand out by spending heavily on advertising and direct-marketing. In 1915, the Wrigley Company kicked off a campaign in which it sent free samples of its gum to millions of Americans listed in phone books. Another promotion entailed sending sticks of gum to U.S. children on their second birthday.

Competition also played a role in the development of bubble gum. Frank Fleer, whose company had made chewing gum since around 1885, wanted something different from his rivals and spent years working on a product that could be blown into bubbles. In 1906, he concocted a bubble gum he called Blibber-Blubber, but it proved to be too sticky. In 1928, a Fleer employee named Walter Diemer finally devised a successful formula for the first commercial bubble gum, dubbed Dubble Bubble.

Today, of course, gum is sold in a variety of shapes and flavors (although, sadly, Willy Wonka’s three-course dinner chewing gum, said to taste like tomato soup, roast beef and blueberry pie, has yet to become reality). And finally, despite what you might’ve been told, if you swallow a piece of gum it’s highly unlikely to end up stuck in your stomach for seven years. Even though gum base is indigestible, it passes through the digestive system harmlessly and is eliminated from the body just like other foods.