On a typical weekday in the U.S., about 50 million kids are in public school all around the country. You can thank mandatory education laws and a robust public school system for that. But how did the United States achieve compulsory education for all, anyway? The roots of the practice might be older than you think—and the laws that got the country on the road to mandatory education have a weird connection to Satan. Yes, Satan.

It all started in the Massachusetts Bay Colony, a settlement of Puritans who emigrated from England. The settlers were part of a “great migration” of Puritans—about 20,000 total—who flocked to New England between 1629 and 1640, driven by a desire to lead pious lives and worship freely. Their religious practices were stern and fervent; as one historian writes, “Puritans lived in a constant state of spiritual anxiety, searching for signs of God's favor or anger.”

One particular worry was Satan—the dark lord capable of leading humanity astray through distractions, deceptions, and any number of temptations. “Satan hath his Mysteries to bring us to Eternal Ruine,” wrote Puritan minister John Hale in a typical anti-Satan screed. “Mysteries not easily understood, whereby the depths of Satan are managed in hidden wayes.”

Every aspect of life in the new colony reflected the Puritan’s preoccupation with the devil’s doings. Massachusetts Puritans enacted strict laws based on their values, and focused on community members’ shared responsibilities to their faith and to each other. Special attention was paid to the moral and educational development of children, who were expected to be obedient and submissive to their elders.

Back in England, the educational system had been haphazard: Rich children were educated by tutors or members of the clergy, while poor ones were left to fend for themselves. The Puritans decided to try another method. In 1642, they passed a law that required every household head to be responsible for the education of all of their children and dependents (servants). The law required that everyone be taught to read, and if a parent failed, their child could be removed from their home.

But by 1647, the Puritan General Court decided that parents in the colony were falling short of their duty. And so the Old Deluder Satan Act was born [PDF]. The law’s name came from its first line, which reminded parents that “one chief project of that old deluder, Satan” was to keep men from reading the Bible. It was thought that Satan would have less power over children who understood “the true sense and meaning” of the Bible, something that could only be guaranteed if the child could read it themselves, without needing to rely on the “false glosses of Saint-seeming-deceivers” for interpretation of scripture.

Instead of relying on parents to educate their kids, the law put the responsibility on towns. Townships with 50 households or more had to fork out money and hire a schoolmaster to teach children to write and read at a “petty” or elementary school. If towns had 100 households or more, they had to set up a petty school as well as a full grammar school—one whose masters were “able to instruct youth so far as they may be fitted for the Universitie.”

Today, the Old Deluder Satan Act is thought of as the nation’s first compulsory education law. It remained on the books until 1789, a year after Massachusetts became a state, when it was incorporated into the Massachusetts Education Act. By then, however, mention of Satan was nowhere to be found.

It took more than a century for the American public school system as we know it to really take hold; before the latter half of the 19th century, not all states had compulsory education laws, and high schools were not yet common [PDF]. That changed during the Progressive Era, when reformers set to work establishing free schools and mandatory education for everyone—and it all started with a group of people convinced that Satan was at work in their community.