The history of Hamburg begins with its foundation in the 9th century as a mission settlement to convert the Saxons. Since the Middle Ages Hamburg was an important trading centre in Europe. The convenient location of the port and its independence as a city and state for centuries strengthened this position. The city was member in the medieval Hanseatic trading league and a free imperial city of the Holy Roman Empire. From 1815 until 1866 Hamburg was an independent and sovereign state of the German Confederation, then the North German Confederation (1866–71), the German Empire (1871–1918) and during the period of the Weimar Republic (1918–33). In Nazi Germany Hamburg was a city-state and a Gau from 1934 until 1945. After the Second World War Hamburg was in the British Zone of Occupation and became a state in the western part of Germany in the Federal Republic of Germany (Since 1949).