Trenčín gained a number of privileges during the Middle Ages: In 1324 the inhabitants were freed from paying tolls and the city received free royal town privileges in 1412 from King Sigismund. However, during the following decades and centuries there were catastrophes and wars which lasted until the end of the 18th century. During the conflict between the Habsburgs and the supporters of the rival king, János Szapolyai, the town was captured in 1528 by imperial troops. In the 17th century the Ottomans were another threat from the south but they failed to conquer the city. The town then suffered from the Kuruc uprising against the Habsburgs and on 3 August 1708 the Battle of Trenčín took place close to the city. Two years later a plague killed 1,600 inhabitants of the city. Finally, in 1790 the town, along with the castle, was burned down and the castle has been in ruins ever since.