Hamburg's history is a rather picaresque tale, dominated by two periods: Hamburg's days as a leading member of the Hanseatic League and the devastation of the city during WWII. Both periods – one which established Hamburg as one of the world's most important ports, the other which brought the city to its knees – continue to define the city's identity and shape the way it sees itself to this day.

Early Years

Hamburg's first appearance in the modern historical record occurs in AD 808. It was then, with the Vikings threatening from the north, that the Emperor Charlemagne of the Holy Roman Empire ordered a castle to be built on what is now Hamburg soil. When emperors ordered such things, they were usually done: Charlemagne's son Louis built the castle a year later. Twenty-three years later, on Christmas Day 831, the town was declared the archbishopric of Hammaburg, as part of a plan to convert the locals.

Having a castle and an archbishop meant little, however, in 845 when the Vikings destroyed the town. It was a pattern that repeated itself over the following centuries. Destroyed again in 880 and 943, for a long while Hamburg was little more than a poorly defended outpost on the outer reaches of empire.

Hanseatic Hamburg

Hamburg’s commercial character was forged in 1189, when local noble Count Adolf III persuaded Emperor Friedrich I (Barbarossa) to grant the city free trading rights and an exemption from customs duties. This transformed the former missionary settlement and 9th-century moated fortress of Hammaburg into an important port.

There are various explanations of the origins of the Hanseatic League, but most historians agree that it took on unstoppable momentum with two contracts signed between the cities of Lübeck and Hamburg in 1241. One of these contracts committed both cities to a mutual defence pact, while the other secured the road between the two cities and ensured that deportees from one city could not find refuge in the other. It was at once a commercial and defensive alliance, joining merchant guilds, and their towns, with other like-minded places. With these seemingly simple ideas, one of the world's great free trading pacts was formed.

Cologne joined with Hamburg and Lübeck in 1260, and over the next two decades, the three cities were granted free-trade access with London under Henry III. Although it never became a formal organisation, other towns also forged agreements that soon linked anywhere between 70 and 170 cities, creating a formidable free trading alliance that extended from Bergen (Norway) to London. Representatives from the Hanseatic towns met on a semi-regular basis in Lübeck, and the Hanseatic cities became increasingly prosperous – the Hanseatic League enabled each of its cities to access a range of markets which would have been unthinkable without the agreements.

Hamburg in particular prospered, its salt, beer and textile exports bringing in new luxury goods to the city, such as silk and linens. The far-reaching sea connections with the rest of Europe also brought cultural advancement to the city – it is often said that the Renaissance took hold across northern Germany far quicker than elsewhere thanks to the Hanseatic League.

The Hanseatic League endured until the 16th century, when the member cities began to put their own interests above those of the collective. The League continued in diminished form until Kaiser Wilhelm I formed the First German Empire – at the time of the League's cessation, just Hamburg, Lübeck and Bremen remained as members.

Hamburg still officially calls itself the Freie und Hansestadt Hamburg (the Free and Hanseatic City of Hamburg).

World War II & Beyond

Hamburg's prosperity began to wane in 1842, when the Great Fire destroyed a third of its buildings. It joined the German Reich in 1871, but the city was then involved in the two devastating world wars. After WWI, most of Hamburg’s merchant fleet (almost 1500 ships) was forfeited to the Allies.

Hamburg was always going to be a prime target for Allied bombing during WWII. As well as being a major industrial centre, it was here that many German ships and U-boats were built. Bombing was constant, but it was Operation Gomorrah, launched during the last week of July 1943, that would finally break the city. Planes from the Royal Air Force and United States Army Air Forces killed between 35,000 and 43,000 civilians in just a few days. The city centre was incinerated, and more than half of Hamburg’s housing, 80% of its port and 40% of its industrial buildings were reduced to rubble. One million people fled the city. It was one of the most devastating weeks in the war.

In the postwar years, Hamburg harnessed its resilience to participate in Germany’s economic miracle (Wirtschaftswunder). Its harbour and its media industries are now the backbone of Hamburg's wealth. The majority of Germany’s largest publications are produced in the city, including news magazines Stern and Der Spiegel.