After the formation of the Duchy of Carinthia in 976, Friesach remained a southern Salzburg exclusive and a strategically important outpost. About 1076 Archbishop Gebhard of Salzburg, a follower of Pope Gregory VII in the Investiture Controversy, had the Petersberg fortress erected above the town in order to prevent Emperor Henry IV from crossing the Alps. The archbishop also had fierce enemies in the Carinthian ducal House of Sponheim, who after his deposition made several attempts to take possession of Friesach. Constant attacks by Duke Engelbert were finally repelled in 1124. In 1149 King Conrad III of Germany stayed at the castle on his way back from the Second Crusade, as did Richard the Lionheart returning from the Third Crusade in 1192, attempting to elude the guards of Duke Leopold V of Austria.