Škofja Loka was walled in the 14th century. In 1457, Duke Jan Vitovec entered and burned the town. The town was attacked by the Ottomans in 1476. The town also suffered from plague and fires during this time. Peasant revolts occurred in Škofja Loka in 1488, 1492, and 1515. Škofja Loka was destroyed by the 1511 earthquake, but soon rebuilt through the efforts of Bishop Phillip.