The castle became known as the seat of Knight Erazem Luegger, owner of the castle in the 15th century and a renowned robber baron. from the 14th century St. George's Cathedral. was the son of the Imperial Governor of Trieste, Nikolaj Lueger. According to legend, Erazem came into conflict with the Habsburg establishment, when he killed the commander of the Imperial army Marshall Pappencheim, who had offended the honour of Erazem's deceased friend, Andrej Baumkircher. Fleeing from the revenge of the Holy Roman Emperor Frederick III , Erazem settled in the family fortress of Predjama. He allied himself with the Hungarian king and began to attack Habsburg estates and towns.
A headstrong and rebellious knight, Erazem rebelled against the Austrian emperor Fredrick III and eventually killed his kinsman. Thus enraged, the Austrian leader commissioned the governor of Trieste, Andrej Ravbar, to capture and kill Erazem. This is when the impregnability of Predjama Castle was tested.
For a year and a day, Erazem was besieged in his fortress. But to the dismay of his adversaries, he continued to survive and taunt the attacking soldiers by pelting them with cherries. They could not understand how he was obtaining supplies. As far as they knew, there was only one way in and out of both the valley and castle; but the Erazem knew better. Unbeknownst to the soldiers, Erazem knew of a secret tunnel leading from the castle, which allowed him to travel to the nearby village of Vipava and collect supplies, including hoards of fresh cherries when in season.
But it seemed that the soldiers were to have the last laugh. With the strategic placement of a small signal flag, a servant of Erazem was bribed to reveal when his master was in attendance at that place where the elusive knight and even the noblest of men needed to go after consuming lots of cherries and wine: the outhouse. Unfortunately for Erazem, the toilet, situated on the top floor and at the very edge of the castle, was the one place that was not impregnable.
When the moment came, the flag was placed there by the treacherous servant. A single cannonball was launched, and Erazem was literally caught with his trousers down.