The name of the city of Hamburg stems from the first known building constructed on the site. Emperor Charlemagne ordered the construction of a castle name Hammaburg built in 808 AD. The built in a marsh somewhere between Alster and the Elbe. The area was very rocky and designed to protect against Slavic attacks, which were veryvalent at the time. Linguists understand that "burg" means "castle," however, they are unsure as to the nature "Hamma." The exact location of the castle is unknown as well.
The city grew very fast, achieving first fame as the seat of a Roman Catholic bishop named Ansgar, the Apostle of the North in 834. Nearly 500 inmates lived here until a fleet of 600 Viking ships raided and destroyed the town in 845.
The city was rebuilt on the same site but suffered a similar fate in 1030. King Mieszko II Lambert of Poland again burned down the city during a brief war. After being rebuilt again, Frederick I, known as "Barbarossa," granted the city a charter in 1189 that stated it was a tax free zone that would allow access to the North Sea via the Lower Elbe, on which Hamburg is located. This caused the city to become one of the fastest-growing ports in Northern Europe. Over the years, the city created trade alliances culminating in a 1241 charter that had Hamburg become a core partner in the powerful Hanseatic League with its trade routes connecting both the North Sea and the Baltic.
During this time, however, the city was twice raided by forces from Denmark who occupied the city in both 1201 and 1214. Despite these events, Henry III issued a contract between London and the city which helped stimulate trade between the two cities in 1266. This was one of the most important trading relationships of the era. To make matters even more impressive, the first laws regarding civil, criminal and procedures were written in 1270. This caused the city to be a culturally important center during the Middle Ages. Again, however, in 1284, a notable fire laid waste to much of the city.
A constitution was written and rated on August 10, 1410. This constitution was one of the first of its kind in Germany. This constitution included provisions for religious tolerance that led the city to embrace Lutheranism. Subsequently, a number of Dutch and French Protestants arrived. This was followed in the 17th century with sephardi Jews arriving from Portugal.
During the Napoleonic Wars, the city was annexed from 1810 to 1814. It was always freed by General Bennisen, a German general who controlled a portion of the Russian army. The city-state became an independent nation within the German Confederation.
1842 marked yet another treacherous year for Hamburg. Now known as the "Great Fire," flames swept through on May 4 and continued to burn for four days. It destroyed much of the inner city including a number of churches and the town hall. 51 people died and nearly 20,000 were left homeless. It took nearly 40 years to rebuild, during which time a republican constitution was formed that stands to this day.