Legend has it that a piper and his dog once ventured into the caves below Scotland’s Culzean Castle, determined to refute locals’ belief that the underground tunnels were haunted. As the pair entered the labyrinthine network, the piper started playing his bagpipes, sending the echo of its shrill wails—occasionally punctuated by the dog’s accompanying barks—from the caves to the castle above. Soon, both bagpipes and barks fell eerily silent. Neither the piper nor his dog were ever seen again—at least not alive. Stop by Culzean (pronounced cull-ane) on a stormy night, particularly one that coincides with when the castle’s one-time clan owners host a wedding, and you may just hear the piper’s doleful last tune, simultaneously celebrating a descendant’s marriage and bemoaning its player’s fate.

Culzean’s vast underground network has long been the subject of speculation amongst locals and historians alike. In addition to boasting its very own ghost, the system hid smugglers during the 17th and 18th centuries. Now, Alison Campsie reports for The Scotsman, archaeologists have unearthed another one of the tunnels’ secrets: a medieval-era doorway that offers passage from the nearby Ayrshire cliffs of southern Scotland to the Culzean caves.

According to a press release, volunteers working with the National Trust for Scotland (NTS) discovered the hidden door during a dig last week. Derek Alexander, NTS head of archaeological services, said that researchers had previously identified a wall and doorway at the mouth of one of the network’s underground tunnels, Castle Cave, but were unaware of a similar entranceway to its counterpart, Stables Cave. Currently, Stables Cave is open to the public, while a stone frontage and barred entrances conceal Castle Cave.

The surviving doorway measures roughly 3.5 feet across and is set into the cave at a depth of about three feet. Stones found near the entranceway indicate the door may have been built into a wall and secured with a bar drawn across its opening. Additional artifacts unearthed during the dig include shards of modern pottery, glass and 18th-century wine bottles.

Alexander says that the archaeologists recently received radiocarbon testing results from a charcoal sample taken at Castle Cave last year. The sample dates to between 135 and 325 A.D., suggesting the cave was occupied during the Iron Age—long before the piper and his pup disappeared within its walls and the towering fortress of Culzean Castle rose to overlook the subterranean network.

Culzean, the ancestral seat of Scotland’s powerful Kennedy clan, is nestled atop a 150-foot cliff overlooking the Firth of Clyde, some 15 miles south of Ayr. According to tourism organization Undiscovered Scotland, the castle traces its origins to a stone tower erected during the late 14th century. Initially known as the House of Cove or Coif Castle—in reference to the cave system found below the tower—the structure was renamed Cullean Castle sometime during the 17th century. By the 18th century, the modern-day spelling, Culzean, had overtaken the earlier title.

Gilbert Kennedy, 4th Earl of Cassilis, gifted the castle and its surrounding lands to his brother, Sir Thomas Kennedy, in 1569. Few significant modifications were made before 1762, when another Thomas Kennedy, the 9th Earl of Cassilis, decided to rebuild the now-dilapidated tower. Thomas’ brother, David, succeeded him as the 10th Earl of Cassilis in 1775 and embarked on an ambitious remodeling campaign led by prominent Palladian architect Robert Adams. Thanks to Adam’s efforts, Culzean gained the Gothic exterior fitted with turrets and towers, sumptuous oval staircase, and three-story west wing that make the castle one of Scotland’s top tourist destinations to this day.

The Culzean caves’ story is decidedly less romantic. According to the BBC, the underground network likely predated any above-ground structures, hosting inhabitants as early as antiquity—a view supported by the archaeologist’s recent findings—and certainly during the medieval period. Given the cove’s secluded location alongside Scotland’s southeastern coast, it’s no wonder that smugglers started incorporating it into their unsavory ventures, hiding contraband ranging from alcohol to tobacco and silks within its sprawling tunnels.

The NTS’ Alexander recounts a less salacious use for the tunnels, noting, “They were used as cellars for storage before Robert Adam converted the castle to the picturesque mansion in the late 18th century.”

Nevertheless, Alexander admits, “There are many tales associated with the caves, which include ghosts, smugglers and hiding fugitives.”