The town has a distinguished history. From the second half of the 10th century until 1918, it was part of the Kingdom of Hungary. A fortress was built as a defence against the Ottoman Turks, on the site of an older settlement in the years 1573–81. Between 1589 and 1663, the settlement was the seat of the Captaincy of Lower Hungary. The town developed around the fortress. The huge new fortress was one of the most modern in Europe when it was built, a prime example of the star fortress which was considered to be adapted to the advance in artillery in the preceding centuries. (In fact, the Hungarian name means "the archbishop's new castle".)