In Britain, ancient artifacts have a way of popping up where you least expect them.

King Richard III’s bones were found buried beneath a parking lot. Roman tablets were revealed during the excavation of Bloomberg’s new London headquarters. And earlier this month, when a maintenance crew went to rewire a room in St. John’s College at the University of Cambridge, they found a shoe in the wall, thought to be about 300 years old.

Unlike the bones or tablets hiding under an undignified crust of modern infrastructure, the shoe had been secreted away in the wall by its contemporaries. The footwear hidden in the wall — about a men’s size 6 today, its sole worn through — had a purpose. The shoe, historians say, was meant to protect academics from evil.

“Given its location, it is very likely that it was there to play a protective role for the Master of the College,” said Richard Newman, a Cambridge archaeologist, in a statement. “It may even have been one of his old shoes.” The position of the shoe, with a window on one side and the chimney interior to the other, “is exactly the sort of location where you would expect to find a shoe being used in this way.”

The earliest record of such shoes dates back to the 1500s. Most were deposited solo, according to the Northampton Museum, and well-worn. Why this trend caught on is a mystery, but scholars believe the practice persisted to the 19th century. (Occasionally, people tucked shoes into the walls through the 1960s, although reports at the time describe it as scratching a time capsule itch, like hiding a dated coin or newspaper.)

Australian settlers borrowed the practice, leading historian Ian Evans to spend a better part of a decade hunting for them. “This is all part of the ancient practice of defeating witches and evil by placing artifacts in those parts of buildings where harmful spirits might lurk,” Evans told the BBC. He argued the practice stuck around at least until the 1920s, which is when a child’s shoe found its way into a pylon in the Sydney Harbor Bridge.

The items fall under a type of popular magic called apotropaios — Greek for “turning away,” as in evil. Such items have been found in structures such as as cottages, pubs and mansions. The nastier objects included horse skulls and cat corpses, although shoes seemed to have a particular anti-witch cachet.

Why shoes held such an appeal is a matter of debate; it is possible they acted as a “spirit trap,” according to the University of Cambridge. Or, perhaps, since footwear could not have been mass manufactured at the time, their custom-made nature, coupled with the fact that leather shoes conformed to the wearer’s foot, imbued the object with the owner’s identity.

Newman said apotropaic items were of particular value, as they had a tendency to survive in the state in which they were employed. “There is not a lot of documentary evidence about people’s beliefs in ritual magic in the past, and often the sources that we have are very negative and disparaging about such practices,” he said. “These discoveries are important because they give us a material record of what people may have believed at the time.”

The old shoe will be returned to the wall, the university said, once researchers are able to determine its exact age.