The city was founded in 972 by Géza of Hungary. It is one of the oldest cities in Hungary. Until 1249 it was the capital of the country. The archbishops built many schools, churches, palaces, and the kings of Hungary built castles. In 1242 the city was attacked and destroyed by mongols, but the castle on the hill was not. After the attack king Béla IV. moved to Buda, and gave the city to the archbishop. In 1543 the city was taken by the Turks, who built many spas. The Hungarians tried to take back the city many times, so it was destroyed again in the wars. The Turks left Esztergom in 1683. In 1822 Alexander Rudnay, the archbishop started building a big temple called a basilica. It is the biggest temple and the tallest building in the country, and the third biggest temple in Europe.