The oldest settlement on the ground of the modern city of Graz dates back to the Copper Age. However, there is no historical continuity of a settlement before the Middle Ages.
During the 12th century dukes under Babenberg rule made the town into an important commercial center. Later Graz came under the rule of the Habsburgs, and in 1281 gained special privileges from King Rudolph I.
In the 14th century Graz became the city of residence of the Inner Austrian line of the Habsburgs. The royalty lived in the Schloßberg castle and from there ruled Styria, Carinthia, most of today's Slovenia and parts of Italy (Carniola, Gorizia and Gradisca, Trieste).
In the 16th century, the city's design and planning were primarily controlled by Italian Renaissance architects and artists. One of the most famous buildings built in this style is the Landhaus, designed by Domenico dell'Allio, and used by the local rulers as a governmental headquarters.
Graz lies in Styria, or called "Steiermark" in German. Mark is an old German word indicating a large area of land used as a defensive border, in which the peasantry are taught how to organize and fight in the case of an invasion. With a strategic location at the head of the open and fertile Mur valley, Graz was often assaulted (unsuccessfully), e.g. by the Hungarians under Matthias Corvinus in 1481, and by the Ottoman Turks in 1529 and 1532. Apart from the Riegersburg, the Schloßberg was the only fortification in the region that never fell to the Ottoman Turks. Graz is home to the region's provincial armory, which is the world's largest historical collection of Baroque weaponry. It has been preserved since 1551, and displays over 30,000 items.
From the earlier part of the 15th century Graz was the residence of the younger branch of the Habsburgs, which succeeded to the imperial throne in 1619 in the person of Emperor Ferdinand II, who moved the capital to Vienna. New fortifications were built on the Schlossberg at the end of the 16th century. Napoleon's army occupied Graz in 1797. In 1809 the city withstood another assault by the French army. During this attack, the commanding officer in the fortress was ordered to defend it with about 900 men against Napoleon's army of about 3,000. He successfully defended the Schloßberg against eight attacks, but they were forced to give up after the Grande Armée occupied Vienna and the Emperor ordered to surrender. Following the defeat of Austria by Napoleonic forces at the Battle of Wagram in 1809, the fortifications were demolished using explosives, as stipulated in the Peace of Schönbrunn of the same year. The belltower and the civic clock tower, often used as the symbol of Graz, were spared after the people of Graz paid a ransom for their preservation.