Holy Roman Emperor Ferdinand II and Danish King Christian IV sign the Treaty of Lübeck to end the Danish intervention in the Thirty Years' War.

Treaty or Peace of Lbeck (Danish: Freden i Lbeck, German: Lbecker Frieden) ended the Danish intervention in the Thirty Years' War (Low Saxon or Emperor's War, Kejserkrigen). It was signed in Lbeck on 22 May 1629 by Albrecht von Wallenstein and Christian IV of Denmark, and on 7 June by Ferdinand II, Holy Roman Emperor. The Catholic League was formally included as a party. It restored to DenmarkNorway its pre-war territory at the cost of final disengagement from imperial affairs.

The Holy Roman Emperor, originally and officially the Emperor of the Romans (Latin: Imperator Romanorum, German: Kaiser der Römer) during the Middle Ages, and also known as the German-Roman Emperor since the early modern period (Latin: Imperator Germanorum, German: Römisch-deutscher Kaiser, lit. 'Roman-German emperor'), was the ruler and head of state of the Holy Roman Empire. The empire was considered by the Roman Catholic Church to be the only successor of the Roman Empire during the Middle Ages and the early modern period. The title was held in conjunction with the title of king of Italy (Rex Italiae) from the 8th to the 16th century, and, almost without interruption, with the title of king of Germany (Rex Teutonicorum, lit. “King of the Teutons”) throughout the 12th to 18th centuries.In theory and diplomacy, the emperors were considered primus inter pares, regarded as first among equals among other Roman Catholic monarchs across Europe.From an autocracy in Carolingian times (AD 800–924) the title by the 13th century evolved into an elective monarchy, with the emperor chosen by the prince-electors.

Various royal houses of Europe, at different times, became de facto hereditary holders of the title, notably the Ottonians (962–1024) and the Salians (1027–1125). Following the late medieval crisis of government, the Habsburgs kept possession of the title without interruption from 1440 to 1740. The final emperors were from the House of Habsburg-Lorraine, from 1765 to 1806. The Holy Roman Empire was dissolved by Francis II, after a devastating defeat by Napoleon at the Battle of Austerlitz.

The emperor was widely perceived to rule by divine right, though he often contradicted or rivaled the pope, most notably during the Investiture controversy. The Holy Roman Empire never had an empress regnant, though women such as Theophanu and Maria Theresa exerted strong influence. Throughout its history, the position was viewed as a defender of the Roman Catholic faith. Until Maximilian I in 1508, the emperor-elect (Imperator electus) was required to be crowned by the pope before assuming the imperial title. Charles V was the last to be crowned by the pope in 1530. Even after the Reformation, the elected emperor was always a Roman Catholic. There were short periods in history when the electoral college was dominated by Protestants, and the electors usually voted in their own political interest.