Szombathely was destroyed during the Mongol invasion of Hungary in 1241–1242 but was rebuilt shortly after. It was granted Free royal town status in 1407. In 1578, it became the capital of Vas comitatus. The city prospered. In 1605 it was occupied by the armies of István Bocskai.