Like many of the world’s most famous traditions, the annual “running of the bulls” in Pamplona, Spain—the encierro—has somewhat foggy origins.

Each July, thousands arrive from across the world in Pamplona from July 7-14 for the San Fermin Festival, named for the patron saint of the town in Spain’s northern Basque region, and to hear the bulls’ hooves hit the cobblestone streets each morning as they charge toward the bold participants, who run them from a pen to the nearby bull ring, where bull fights commence.

The tradition may date back to the 13th century and, though it can now sound like a pretty frivolous thing to do (and several runners have died throughout the run’s history) the origins of running with bulls were very practical.

As TIME reported in 1937, the practice of racing in front of bulls to guide them to their pens or ring was in place before the festival began. It was typically used by cattle herders and butchers attempting to guide bulls from the barges on which they arrived to town, to an enclosure in the middle of the night. It’s not entirely clear when townspeople joined in on the run as a feat of bravery.

Get your history fix in one place: sign up for the weekly TIME History newsletter

Meanwhile, the fiesta of San Fermin was carried on as a religious event intended to honor Pamplona’s first bishop, San Fermin, who was beheaded in France while preaching the gospel in the early the third century. The event was held in the fall, rather than in July. Eventually, as the run became a Pamplona tradition rather than just a thing that butchers did for work, the more religious aspects of San Fermin and the encierro merged.

The modern running course for the bull run was set up sometime later to prevent bulls from escaping into the streets. Peter N. Milligan, a 46-year-old New Jersey lawyer and author of the memoir Bulls Before Breakfast, who has run with the bulls more than 70 times, says townspeople date the modern running course back to 1776, though he admits there aren’t “really good records” for the run’s origins.

The July fiesta in Pamplona was later romanticized by Ernest Hemingway’s visit and resulting novel The Sun Also Rises in 1926, as well as by the countless tales of revelers who had lived to tell their tales.

By now, Pamplona’s isn’t the only bull run in Spain, let alone the world. Even the United States has had a few bull runs of its own — though some, like Milligan, say those aren’t real bull runs.

“Pamplona is like the Super Bowl of the bull runs,” he says.

And there, despite less than glamorous beginnings, tradition endures.

Even today, Milligan says, revelers ask San Fermin for protection and guidance before the run.

Get our History Newsletter. Put today's news in context and see highlights from the archives. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Contact us at letters@time.com.