Early Hungarian
Grand Prince Géza of the Árpád dynasty was the nominal overlord of all seven Magyar tribes but in reality ruled only part of the united territory. He aimed to integrate Hungary into Christian Western Europe by rebuilding the state according to the Western political and social models. Géza founded the Hungarian town in 972 on four moorland islands between the Gaja stream and its tributary, the Sárvíz, one of the most important Hungarian tributaries of the Danube. He also had a small stone castle built. Székesfehérvár was first mentioned in a document by the Bishopric of Veszprém, 1009, as Alba Civitas.
István I, Grand Prince of the Hungarians, granted town rights to the settlement, surrounded the town with a plank wall, and founded a school and a monastery. Under his rule the construction of the Romanesque Székesfehérvár Basilica began (it was built between 1003 and 1038). The settlement had about 3,500 inhabitants at this time and was the royal seat for hundreds of years. 43 kings were crowned in Székesfehérvár (the last one in 1526) and 15 kings were buried here (the last one in 1540), including King St. Stephen I, Hungary's first monarch. In the past few decades, archaeologists have excavated medieval ruins, including those of the Romanesque basilica and the mausoleum of King István I; they can now be visited.
In the 12th century, the town prospered; churches, monasteries, and houses were built. It was an important station on the pilgrim route to the Holy Land. András II issued the Golden Bull here in 1222. The Bull included the rights of nobles and the duties of the king, and the Constitution of Hungary was based on it until 1848. It is often compared to England's Magna Carta.
During the Mongol invasion of Hungary (1241–1242), the invaders could not get close to the castle: Kadan ruled Mongol warriors could not get through the surrounding marshes because of flooding caused by melting snow. In the 13th–15th centuries, the town prospered, and several palaces were built. In the 14th century, Székesfehérvár was surrounded by city walls.
After the death of King Mátyás (1490), the German army of 20,000 men led by the Holy Roman Emperor Maximilian I invaded Hungary. They advanced into the heart of Hungary and captured the city of Székesfehérvár, which they sacked, as well as the tomb of King Mátyás, which was kept there. His Landsknechts were still unsatisfied with the plunder and refused to go for taking Buda. He returned to the Empire in late December and the Hungarian troops liberated Székesfehérvár in the next year.