Sometimes, the only motivation people need to dance is a good beat. Other times, they need tremendous stress within their community — then they can dance for months on end until they collapse. At least that’s what happened in the summer of 1518 in Strasbourg, a part of the Holy Roman Empire that is now on the French side of the Rhine River, near the border with Germany.

It all began with a woman who had an uncontrollable urge to dance. She “stepped into the street and began to silently twist, twirl and shake” and never stopped, says. Soon dozens of others were joining her; the tally reached about 400 desperate dancers all around the city by the next month.

“This wasn’t a sedate affair; the dancers’ feet often ended up bruised and bloody,” Discover explains. Some of the dancers, unable to stop the rhythm moving through their bodies, died of exhaustion.

Authorities at first thought the afflicted had “hot blood” and could dance it out of their systems, and provided music and professional dancers to help them along. But the dancing just would not end. The BBC reports that after more than a month of the gyrating, the victims were loaded onto wagons “and taken to a healing shrine.”

As ridiculous as it sounds, the dancing epidemic in Strasbourg was not the only one of its kind. Other contagious dance outbreaks were reported over the course of a few hundred years up and down the Rhine and in modern-day Switzerland, Germany, Belgium and Holland, but none were as large, well-documented, or deadly as the Strasbourg affair.

Why did these people dance until they dropped? Experts have ruled out ergot poisoning, a commonly suggested condition that causes hallucinations after the victim ingests a certain kind of mold that grows on rye, because the negative physical effects of the illness would hinder proper dancing, among other reasons. They also have crossed out the plague being a stunt by a satanic cult, historian John Waller writes for the BBC, because “contemporaries were certain that the afflicted did not want to dance and the dancers themselves, when they could, expressed their misery and need for help.” Mass hysteria seems to be the top contender as the dancing condition’s culprit.

At the time of the outbreak, people in Strasbourg were fighting off famine and disease. “And, crucially, we also know they believed in a saint called St. Vitus who had the power to take over their minds and inflict a terrible, compulsive dance,” Waller says. “So the epidemic, I argue, was a result of both desperation and pious fear.”

Mass hysteria spreads quickly when triggered in times of great stress, and while it commonly causes fainting, nausea and hyperventilating, it can twist the mind as far as creating hallucinations.

The historian Waller has written about the Strasbourg dancing plague many times, including an article in the journal Endeavor, “In a spin: the mysterious dancing epidemic of 1518,” in which he notes that the dancers rarely stopped to eat, drink or rest. While at first the hired musicians and dancers worked to keep the infected people moving at a steady tempo, eventually the authorities realized something more was going on than their original “hot blood” theory.

“Hence, a period of organised contrition was instituted: gambling, gaming and prostitution were banned and the dissolute driven beyond the city gates,” Waller wrote in Endeavor. “Soon after the dancers were despatched to a mountaintop shrine in the Vosges mountains to pray for divine intercession. There they were led around an altar, wearing red shoes provided for the ceremony, upon which stood a bas-relief carving of St. Vitus, the Virgin and Pope Marcellus. In the following weeks the epidemic abated. Most of the dancers, we are told, regained bodily control.”

So the next time you see somebody dancing in the street, exercise caution before joining the party — you may be helping to create the next dancing epidemic.