In 1226 Emperor Frederick II declared the city of Lübeck to be a Free Imperial City. Lübeck law was the constitution of the city's municipal form of government developed after being made a free city. In theory, Lübeck law made the cities which had adopted it independent of royalty. In the 14th century Lübeck became the "Queen of the Hanseatic League", being by far the largest and most powerful member of this medieval trade organization.
In 1359 Lübeck bought the ducal Herrschaft of Mölln from the indebted Albert V, Duke of Saxe-Bergedorf-Mölln, a branch of the ducal house of Saxe-Lauenburg. The City and Duke—with the consent of the Duke's brother Eric—agreed on a price of 9,737.50 Lübeck marks. The parties also agreed to a clause allowing for the repurchase of the lands by the Duke or his heirs, but only if they were buying back the property for themselves and not for a third party. Lübeck considered this acquisition to be crucially important, since Mölln was an important staging post in the trade (especially the salt trade) between Scandinavia and the cities of Brunswick and Lunenburg via Lübeck. Therefore, Lübeck manned Mölln with armed guards to maintain law and order on the roads.
In 1370 Lübeck further acquired—by way of collateral for a loan—the Lordship of Bergedorf, the Vierlande, half the Sachsenwald (Saxon Forest) and Geesthacht from Duke Eric III, who had meanwhile succeeded his late brother Albert V. This acquisition included much of the trade route between Hamburg and Lübeck, thus providing a safe freight route between the cities. Eric III retained a life tenancy of these lands.
Movement of 680 ships entered/left Port, 18 Mar 1368–10 Mar 1369
Lübeck and Eric III further stipulated that once Eric had died, Lübeck would be entitled to take possession of the pledged territories until his successors could repay the debt and simultaneously exercise the repurchase of Mölln. By this stage the sum involved was calculated as 26,000 Lübeck Marks, an enormous amount of money at that time.
In 1401 Eric III died without issue and was succeeded by his second cousin Eric IV, Duke of Saxe-Ratzeburg-Lauenburg. In the same year Eric IV, supported by his sons Eric (later reigning as Eric V) and John (later John IV), captured the pawned lands without making the agreed repayment and before Lübeck could take possession of them. Lübeck acquiesced.
In 1420 Eric V attacked Frederick I, Elector of Brandenburg and Lübeck gained Hamburg for a war alliance in support of Brandenburg. The armies of both cities opened a second front and conquered Bergedorf, Riepenburg castle and the Esslingen river toll station (today's Zollenspieker Ferry) within weeks. This forced Eric V to agree to the Peace of Perleberg on 23 August 1420, which stipulated that all the pawned territories, which Eric IV, Eric V and John IV had violently taken in 1401, were to be ceded irrevocably to the cities of Hamburg and Lübeck. The cities transformed the gained areas into the "Beiderstädtischer Besitz" (condominium of both cities), ruled by bailiffs for four-year terms. The bailiffs were to come from each of the cities alternately.
The Hanseatic League, under Lübeck´s leadership, fought several wars against Denmark with varying degrees of success. Whilst Lübeck and the Hanseatic League won in 1435 and 1512, Lübeck lost when it became involved in the Count's Feud, a civil war that raged in Denmark from 1534 to 1536. Lübeck also joined the Schmalkaldic League. After its defeat in the Count's Feud, Lübeck's power slowly declined. Lübeck remained neutral in the Thirty Years' War, but with the devastation of the war and the new transatlantic orientation of European trade, the Hanseatic League, and thus Lübeck, lost importance. After the de facto disbandment of the Hanseatic League in 1669, Lübeck remained an important trading town on the Baltic Sea.
Lübeck remained a Free Imperial City even after the German Mediatisation in 1803 and became a sovereign state at the dissolution of the Holy Roman Empire in 1806. During the War of the Fourth Coalition against Napoleon, troops under Bernadotte occupied neutral Lübeck after a battle against Blücher on 6 November 1806.
Lübeck reassumed its pre-1811 status in 1813. The 1815 Congress of Vienna reconfirmed Lübeck's independence and it became one of 39 sovereign states of the German Confederation. Lübeck joined the North German Confederation in 1867. The following year Lübeck sold its share in the bi-urban condominium of Bergedorf to the Free and Hanseatic City of Hamburg, which was also a sovereign state of the North German Confederation. In 1871 Lübeck became an autonomous component state within the newly founded German Empire. Its status was weakened during the Weimar Republic by the Republic's enforcement of its right to determine state and Reich taxes. In 1933, in the course of the Gleichschaltung, Lübeck's senate (the city government) and Bürgerschaft (parliament) were streamlined in order to manufacture Nazi majorities. By 1935 the statehood of Lübeck, like that of all German states, had faded completely, without being formally suspended.
In 1937 the Nazis passed the Greater Hamburg Act, whereby the nearby Hanseatic City of Hamburg was expanded to include towns that had formerly belonged to the Prussian province of Schleswig-Holstein. To compensate Prussia for these losses (and partly because Adolf Hitler had a personal dislike for Lübeck after it refused to allow him to campaign there in 1932 and because the flag of Lübeck was extremely similar to the flag of Poland, (which Hitler hated) the 711-year-long statehood of Lübeck came to an end and almost all its territory was incorporated into Schleswig-Holstein.
Lübeck was occupied by the British Army in the closing days of World War II. The Soviet Army later occupied all territory to the east of the city, as agreed by the Allied powers. Prussia was dissolved as a state by the occupying Allied forces after the war. However, unlike Hamburg and Bremen, Lübeck was not restored to statehood. Instead the city was incorporated into the new federal state of Schleswig-Holstein. Lübeck's position on the inner German border, which cut off the city from much of its hinterland, was a key factor in this development. In 1956, the West German Federal Constitutional Court upheld a decision by the federal government to strike down an attempt to restore Lübeck's statehood by referendum (→Lübeck-Urteil).