

Kraków's prehistory begins with evidence of a Stone Age settlement on the present site of the Wawel Hill. A legend attributes Kraków's founding to the mythical ruler Krakus, who built it above a cave occupied by a dragon, Smok Wawelski. The first written record of the city's name dates back to 966, when Kraków was described as a notable commercial center owned by the Bohemian duke.
By the end of the 10th century, the city was a leading trading center, incorporated into the holdings of the Piast dynasty. Brick buildings were constructed, including the Wawel Castle, Romanesque churches such as St. Adalbert's, a cathedral, and a basilica. The city was almost entirely destroyed during the Mongol invasions of 1241, 1259 and 1287. It was rebuilt and incorporated in 1257, based on the Magdeburg law, with tax benefits and trade privileges for its citizens. These citizens were German settlers who moved in during the Ostsiedlung and who constituted a majority of burghers in contemporary Polish and Bohemian towns. The 1257 foundation decree issued by Bolesław V the Chaste was unusual in that it explicitly excluded the local population. The older royal fort Wawel was connected to the new town, built on its northern side around the market square, by its former suburbium (Okol). Germans constituted the majority during the 14th century and became Polonized by the 16th century. The city rose to prominence in 1364, when Casimir III of Poland founded the University of Kraków, the second oldest university in central Europe after the Charles University in Prague. The city continued to grow under the joint Lithuanian-Polish Jagiellon dynasty. As the capital of the Kingdom of Poland and a member of the Hanseatic League, the city attracted many craftsmen, businesses, and guilds as science and the arts began to flourish.
The 15th and 16th centuries were known as Poland's Złoty Wiek or Golden Age. Many works of Polish Renaissance art and architecture were created then, including ancient synagogues in Kraków's Jewish quarter of Kazimierz, such as the Old Synagogue. During the reign of Casimir IV, various artists came to work and live in Kraków, and Johann Haller established a printing press in the city after Kasper Straube had printed the Calendarium Cracoviense, the first work printed in Poland, in 1473.
In 1520, the most famous church bell in Poland, named Zygmunt after Sigismund I of Poland, was cast by Hans Behem. At that time, Hans Dürer, a younger brother of Albrecht Dürer, was Sigismund's court painter. Hans von Kulmbach made altarpieces for several churches. In 1572, King Sigismund II, the last of the Jagiellons, died childless. The Polish throne passed to Henry III of France and then to other foreign-based rulers in rapid succession, causing a decline in the city's importance that was worsened by pillaging during the Swedish invasion and by an outbreak of bubonic plague that left 20,000 of the city's residents dead. In 1596, Sigismund III of the Swedish House of Vasa moved the capital of the Polish-Lithuanian Commonwealth from Kraków to Warsaw.
Already weakened during the 18th century, by mid-1790 the Polish-Lithuanian Commonwealth had been twice partitioned by its neighbors: Russia, the Habsburg empire, and Prussia. In 1794, Tadeusz Kościuszko initiated an unsuccessful insurrection in the town's Main Square which, in spite of his victorious Battle of Racławice against numerically superior Russian army, resulted in the third and final partition of Poland. Following the Uprising, Kraków became part of the Austrian partition in a province of Kingdom of Galicia and Lodomeria. In 1809, Napoleon Bonaparte captured former Polish territories from Austria and made the town part of the Duchy of Warsaw. Following Napoleon's defeat in Russia, the Congress of Vienna in 1815 mostly restored earlier structures, although it also created the partially independent Free City of Kraków. As in 1794, an insurrection in 1846 failed; resulting in the city being annexed by Austria under the name the Grand Duchy of Krakow.
In 1866, Austria granted a degree of autonomy to Galicia after the Austro-Prussian War, and Kraków became a Polish national symbol and a center of culture and art, known frequently as the "Polish Athens" (Polskie Ateny) or "Polish Mecca". Many leading Polish artists of the period resided in Kraków, among them the seminal painter Jan Matejko, laid to rest at Rakowicki Cemetery, and the founder of modern Polish drama, Stanisław Wyspiański. Fin de siècle Kraków evolved into a modern metropolis; running water and electric streetcars were introduced in 1901, and between 1910 and 1915, Kraków and surrounding suburban communities were gradually combined into a single administrative unit called Greater Kraków (Wielki Kraków).
At the outbreak of World War I on 3 August 1914, Józef Piłsudski formed a small cadre military unit, the First Cadre Company—the predecessor of the Polish Legions—which set out from Kraków to fight for the liberation of Poland. The city was briefly besieged by Russian troops in November 1914, but they were pushed back afterwards. The Austrian rule in Kraków ended in 1918 when the Polish Liquidation Committee assumed power.
With the emergence of the Second Polish Republic, Kraków restored its role as a major academic and cultural center with the establishment of new universities such as the AGH University of Science and Technology and the Jan Matejko Academy of Fine Arts, including a number of new and essential vocational schools. It became an important cultural center for the Polish Jews with a Zionist youth movement relatively strong among the city's Jewish population. Kraków was also an influential center of Jewish spiritual life, with all its manifestations of religious observance from Orthodox, to Chasidic and Reform flourishing side by side.
Following the invasion of Poland in September 1939, the Nazi German forces turned the city into the capital of the General Government, a colonial authority headed by Hans Frank and seated in Wawel Castle. In an operation called "Sonderaktion Krakau", more than 180 university professors and academics were arrested and sent to Sachsenhausen and Dachau concentration camps, though the survivors were later released on the request of prominent Italians. The Jewish population was first confined to a ghetto and later murdered or sent to concentration camps, including Płaszów and Auschwitz in Oświęcim. Roman Polański, the film director, is a survivor of the Ghetto, while Oskar Schindler, the German businessman portrayed in the Steven Spielberg film Schindler's List, selected employees from the Ghetto to work in his enamelware plant (known as Emalia), thus saving them from the camps.
Kraków remained relatively undamaged at the end of World War II. After the war, under the Stalinist regime, the intellectual and academic community of Kraków was put under total political control. The universities were soon deprived of their printing rights as well as their autonomy. The communist government of the People's Republic of Poland ordered construction of the country's largest steel mill in the newly created suburb of Nowa Huta. The creation of the giant Lenin Steelworks (now Sendzimir Steelworks owned by Mittal) sealed Kraków's transformation from a university city to an industrial center. The new working class, drawn by the industrialization of the city, contributed to its rapid population growth. Also, in an effort that spanned two decades, Karol Wojtyła, cardinal archbishop of Kraków, successfully lobbied for permission to build the first churches in the new industrial suburbs.
In 1978, UNESCO placed Kraków on the list of World Heritage Sites. In the same year, Karol Wojtyła was elevated to the papacy as John Paul II, the first non-Italian pope in 455 years.