Founded in the first decade of the 9th century as Hamma Burg
("fortified town"), it was designated the seat of a bishopric (834) whose first bishop Ansgar became known as the Apostle of the North.
In 845 a fleet said to number 600 Viking ships came up the River Elbe and destroyed Hamburg, at that time a place of around 500 inhabitants.
Two years after that Hamburg was united with Bremen as the bishopric of Hamburg-Bremen.
In 1030 the city was burned down by King Mieszko II of Poland.
The see was finally moved to Bremen after further raids in 1066 and 1072, this time by Slavs from the east.
Frederick I "Barbarossa is said to have granted free access up the Lower Elbe to Hamburg in a charta of 1189. Hamburg's proximity to the main trade routes of the North and Baltic Seas quickly made it a major port of Northern Europe, and its alliance (1241) with Lübeck on the Baltic is considered the origin of the powerful Hanseatic League of trading cities. However, Frederick's document, still at display at the town museum, is known to be a fake from around 1265. Therefore Hamburg does not hold city rights.
In the 1520s the city authorities embraced Lutheranism, and Hamburg subsequently received Protestant refugees from the Netherlands and France. At times under Danish sovereignty while a part of the Holy Roman Empire, in 1768 it gained full Danish recognition as an Imperial Free City.
Annexed briefly by France (1810-14), Hamburg suffered severely during Napoleon I's last campaign in Germany, but experienced its fastest growth during the second half of the 19th century, when its population more than quadrupled to 800,000 as the growth of the city's Atlantic trade helped make it Europe's third-largest post.
Jungfernstieg in Hamburg, view across the River Alster with fountain (May 2003)
Hamburg was destroyed by fire several times, notably in