As Roman power in Gaul declined during the 5th century, local Germanic tribes assumed control. In the late 5th and early 6th centuries, the Merovingians, under Clovis I and his successors, consolidated Frankish tribes and extended hegemony over others to gain control of northern Gaul and the middle Rhine river valley region.

Although antagonism about the expense of Byzantine domination had long persisted within Italy, a political rupture was set in motion in earnest in 726 by the iconoclasm of Emperor Leo III the Isaurian, in what Pope Gregory II saw as the latest in a series of imperial heresies.

By the middle of the 8th century, however, the Merovingians had been reduced to figureheads, and the Carolingians, led by Charles Martel, had become the de facto rulers.

In 751, Martel's son Pepin became King of the Franks, and later gained the sanction of the Pope. The Carolingians would maintain a close alliance with the Papacy.

In 768, Pepin's son Charlemagne became King of the Franks and began an extensive expansion of the realm. He eventually incorporated the territories of present-day France, Germany, northern Italy, and beyond, linking the Frankish kingdom with Papal lands.

The Holy Roman Empire never had a single permanent/fixed capital city. Usually, the Holy Roman Emperor ruled from a place of his own choice. This was called an imperial seat. Seats of the Holy Roman Emperor included: Aachen (from 794), Palermo (1220–1254), Munich (1328–1347 and 1744–1745), Prague (1355–1437 and 1576–1611), Brussels (1516–1556), Vienna (1438–1576, 1611–1740 and 1745–1806) and Frankfurt am Main (1742–1744) among other cities.

In 797, the Eastern Roman Emperor Constantine VI was removed from the throne by his mother Irene who declared herself Empress. As the Latin Church, influenced by Gothic law forbidding female leadership and property ownership, only regarded a male Roman Emperor as the head of Christendom, Pope Leo III sought a new candidate for the dignity, excluding consultation with the Patriarch of Constantinople. Charlemagne's good service to the Church in his defense of Papal possessions against the Lombards made him the ideal candidate.

On Christmas Day of 800, Pope Leo III crowned Charlemagne emperor, restoring the title in the West for the first time in over three centuries.

This can be seen as symbolic of the papacy turning away from the declining Byzantine Empire towards the new power of Carolingian Francia. Charlemagne adopted the formula Renovatio imperii Romanorum ("renewal of the Roman Empire"). In 802, Irene was overthrown and exiled by Nikephoros I and henceforth there were two Roman Emperors.

After Charlemagne died in 814, the imperial crown passed to his son, Louis the Pious.

By this point the territory of Charlemagne had been divided into several territories, and over the course of the later ninth century the title of Emperor was disputed by the Carolingian rulers of Western Francia and Eastern Francia, with first the western king (Charles the Bald) and then the eastern (Charles the Fat), who briefly reunited the Empire, attaining the prize; however, after the death of Charles the Fat in 888 the Carolingian Empire broke apart, and was never restored. According to Regino of Prüm, the parts of the realm "spewed forth kinglets", and each part elected a kinglet "from its own bowels".

Upon Louis (Louis the Pious)' death in 840, it passed to his son Lothair, who had been his co-ruler.

Around 900, autonomous stem duchies (Franconia, Bavaria, Swabia, Saxony, and Lotharingia) reemerged in East Francia. After the Carolingian king Louis the Child died without issue in 911, East Francia did not turn to the Carolingian ruler of West Francia to take over the realm but instead elected one of the dukes, Conrad of Franconia (Conard I of Germany), as Rex Francorum Orientalium.

After the death of Charles the Fat, those crowned emperor by the pope controlled only territories in Italy. The last such emperor was Berengar I of Italy, who died in 924.

On his deathbed, Conrad of Franconia yielded the crown to his main rival, Henry the Fowler of Saxony (r. 919–36), who was elected king at the Diet of Fritzlar in 919.

Henry (Henry the Fowler) reached a truce with the raiding Magyars, and in 933 he won a first victory against them in the Battle of Riade. The Battle of Riade or Battle of Merseburg was fought between the troops of East Francia under King Henry I and the Magyars at an unidentified location in northern Thuringia along the river Unstrut on 15 March 933. The battle was precipitated by the decision of the Synod of Erfurt to stop paying an annual tribute to the Magyars in 932.

Henry died in 936, but his descendants, the Liudolfing (or Ottonian) dynasty, would continue to rule the Eastern kingdom for roughly a century. Upon Henry the Fowler's death, Otto, his son and designated successor, was elected King in Aachen in 936. He overcame a series of revolts from a younger brother and from several dukes. After that, the king managed to control the appointment of dukes and often also employed bishops in administrative affairs.

In 951, Otto came to the aid of Adelaide, the widowed queen of Italy, defeating her enemies, marrying her, and taking control over Italy.

In 955, Otto won a decisive victory over the Magyars (Hungarians) in the Battle of Lechfeld. The Battle of Lechfeld was a series of military engagements over the course of three days from 10–12 August 955 in which the German forces of King Otto I the Great annihilated a Hungarian army led by harka Bulcsú and the chieftains Lél and Súr. With this German victory, further invasions by the Magyars into Latin Europe were ended.

In 962, Otto was crowned Emperor by Pope John XII, thus intertwining the affairs of the German kingdom with those of Italy and the Papacy. Otto's coronation as Emperor marked the German kings as successors to the Empire of Charlemagne, which through the concept of translatio imperii, also made them consider themselves as successors to Ancient Rome.

The Holy Roman Empire became eventually composed of four kingdoms. The kingdoms were: Kingdom of Germany (part of the empire since 962), Kingdom of Italy (from 962 until 1648), Kingdom of Bohemia (since 1002 as the Duchy of Bohemia and raised to a kingdom in 1198), Kingdom of Burgundy (from 1032 to 1378).

In 963, Otto deposed the current Pope John XII and chose Pope Leo VIII as the new pope (although John XII and Leo VIII both claimed the papacy until 964 when John XII died). This also renewed the conflict with the Eastern Emperor in Constantinople, especially after Otto's son Otto II (r. 967–83) adopted the designation imperator Romanorum. Still, Otto II formed marital ties with the east when he married the Byzantine princess Theophanu.

Otto III (Otto's II son), came to the throne only three years old, and was subjected to a power struggle and series of regencies until his age of majority in 994. Up to that time, he had remained in Germany, while a deposed Duke, Crescentius II, ruled over Rome and part of Italy, ostensibly in his stead.

In 996, Otto III appointed his cousin Gregory V the first German Pope.

The House of Habsburg (alternatively spelled Hapsburg in English), also officially called the House of Austria, was one of the most influential and distinguished royal houses of Europe. The throne of the Holy Roman Empire was continuously occupied by the Habsburgs from 1438 until their extinction in the male line in 1740. The house also produced kings of Bohemia, Hungary, Croatia, Galicia, Portugal and Spain with their respective colonies, as well as rulers of several principalities in the Netherlands and Italy. From the 16th century, following the reign of Charles V, the dynasty was split between its Austrian and Spanish branches. Although they ruled distinct territories, they nevertheless maintained close relations and frequently intermarried.

Otto died young in 1002, and was succeeded by his cousin Henry II, who focused on Germany.

Henry II died in 1024 and Conrad II, first of the Salian Dynasty, was elected king only after some debate among dukes and nobles. This group eventually developed into the college of Electors.

Kings often employed bishops in administrative affairs and often determined who would be appointed to ecclesiastical offices. In the wake of the Cluniac Reforms, this involvement was increasingly seen as inappropriate by the Papacy. The reform-minded Pope Gregory VII was determined to oppose such practices, which led to the Investiture Controversy with Henry IV (r. 1056–1106), the King of the Romans and Holy Roman Emperor.

The Pope, in turn, excommunicated the king, declared him deposed, and dissolved the oaths of loyalty made to Henry IV. The king found himself with almost no political support and was forced to make the famous Walk to Canossa in 1077, by which he achieved a lifting of the excommunication at the price of humiliation. Meanwhile, the German princes had elected another king, Rudolf of Swabia.

The Hohenstaufen, also called Staufer, was a noble dynasty of unclear origin that rose to rule the Duchy of Swabia from 1079 and to royal rule in the Holy Roman Empire during the Middle Ages from 1138 until 1254. The most prominent kings Frederick I (1155), Henry VI (1191) and Frederick II (1220) ascended the imperial throne and also ruled Italy and Burgundy. The non-contemporary name is derived from a family castle on the Hohenstaufen mountain at the northern fringes of the Swabian Jura near the town of Göppingen. Under Hohenstaufen reign the Holy Roman Empire reached its greatest territorial extent from 1155 to 1268.

Henry IV repudiated the Pope's interference and persuaded his bishops to excommunicate the Pope, whom he famously addressed by his born name "Hildebrand", rather than his regnal name "Pope Gregory VII".

Henry managed to defeat him but was subsequently confronted with more uprisings, renewed excommunication, and even the rebellion of his sons. After his death, his second son, Henry V, reached an agreement with the Pope and the bishops in the 1122 Concordat of Worms.

When the Salian dynasty ended with Henry V's death in 1125, the princes chose not to elect the next of kin, but rather Lothair, the moderately powerful but already old Duke of Saxony. When he died in 1137, the princes again aimed to check royal power; accordingly they did not elect Lothair's favoured heir, his son-in-law Henry the Proud of the Welf family, but Conrad III of the Hohenstaufen family, the grandson of Emperor Henry IV and thus a nephew of Emperor Henry V. This led to over a century of strife between the two houses. Conrad ousted the Welfs from their possessions, but after his death in 1152, his nephew Frederick I "Barbarossa" succeeded him and made peace with the Welfs, restoring his cousin Henry the Lion to his – albeit diminished – possessions.

Frederick I, also called Frederick Barbarossa, was crowned Emperor in 1155. He emphasized the "Romanness" of the empire, partly in an attempt to justify the power of the Emperor independent of the (now strengthened) Pope. An imperial assembly at the fields of Roncaglia in 1158 reclaimed imperial rights in reference to Justinian's Corpus Juris Civilis. Imperial rights had been referred to as regalia since the Investiture Controversy but were enumerated for the first time at Roncaglia. This comprehensive list included public roads, tariffs, coining, collecting punitive fees, and the investiture or seating and unseating of office holders. These rights were now explicitly rooted in Roman Law, a far-reaching constitutional act.

Before 1157, the realm was merely referred to as the Roman Empire. The term sacrum ("holy", in the sense of "consecrated") in connection with the medieval Roman Empire was used beginning in 1157 under Frederick I Barbarossa ("Holy Empire"): the term was added to reflect Frederick's ambition to dominate Italy and the Papacy. The form "Holy Roman Empire" is attested from 1254 onward.

In 1190, Frederick participated in the Third Crusade and died in the Armenian Kingdom of Cilicia.

Under the son and successor of Frederick Barbarossa, Henry VI, the Hohenstaufen dynasty reached its apex. Henry added the Norman kingdom of Sicily to his domains, held English king Richard the Lionheart captive, and aimed to establish a hereditary monarchy when he died in 1197.

As his son, Frederick II, though already elected king, was still a small child and living in Sicily, German princes chose to elect an adult king, resulting in the dual election of Frederick Barbarossa's youngest son Philip of Swabia and Henry the Lion's son Otto of Brunswick, who competed for the crown. Otto prevailed for a while after Philip was murdered in a private squabble in 1208 until he began to also claim Sicily.

The Kingdom of Bohemia was a significant regional power during the Middle Ages. In 1212, King Ottokar I (bearing the title "king" since 1198) extracted a Golden Bull of Sicily (a formal edict) from the emperor Frederick II, confirming the royal title for Ottokar and his descendants and the Duchy of Bohemia was raised to a kingdom. Bohemian kings would be exempt from all future obligations to the Holy Roman Empire except for participation in the imperial councils. Charles IV set Prague to be the seat of the Holy Roman Emperor.

Despite his imperial claims, Frederick's rule was a major turning point towards the disintegration of central rule in the Empire. While concentrated on establishing a modern, centralized state in Sicily, he was mostly absent from Germany and issued far-reaching privileges to Germany's secular and ecclesiastical princes: in the 1220 Confoederatio cum principibus ecclesiasticis, Frederick gave up a number of regalia in favor of the bishops, among them tariffs, coining, and fortification.

Pope Innocent III, who feared the threat posed by a union of the empire and Sicily, was now supported by Frederick II, who marched to Germany and defeated Otto. After his victory, Frederick did not act upon his promise to keep the two realms separate. Though he had made his son Henry king of Sicily before marching on Germany, he still reserved real political power for himself. This continued after Frederick was crowned Emperor in 1220. Fearing Frederick's concentration of power, the Pope finally excommunicated the Emperor. Another point of contention was the crusade, which Frederick had promised but repeatedly postponed.

Frederick led the Sixth Crusade in 1228, which ended in negotiations and a temporary restoration of the Kingdom of Jerusalem.

The 1232 Statutum in favorem principum mostly extended these privileges to secular territories. Although many of these privileges had existed earlier, they were now granted globally, and once and for all, to allow the German princes to maintain order north of the Alps while Frederick II concentrated on Italy. The 1232 document marked the first time that the German dukes were called domini terræ, owners of their lands, a remarkable change in terminology as well.

Conrad IV's death was followed by the Interregnum, during which no king could achieve universal recognition, allowing the princes to consolidate their holdings and become even more independent rulers.

After the death of Frederick II in 1250, the German kingdom was divided between his son Conrad IV (died 1254) and the anti-king, William of Holland (died 1256).

After 1257, the crown was contested between Richard of Cornwall, who was supported by the Guelph party, and Alfonso X of Castile, who was recognized by the Hohenstaufen party but never set foot on German soil.

After Richard's death (Richard of Cornwall) in 1272, Rudolf I of Germany, a minor pro-Staufen count, was elected. He was the first of the Habsburgs to hold a royal title, but he was never crowned emperor.

In 1282, Rudolf I thus lent Austria and Styria to his own sons.

After Rudolf's death in 1291, Adolf and Albert were two further weak kings who were never crowned emperor. Adolf of Germany (c. 1255 – 2 July 1298) was Count of Nassau from about 1276 and elected King of Germany (King of the Romans) from 1292 until his deposition by the prince-electors in 1298. He was never crowned by the Pope, which would have secured him the title of Holy Roman Emperor. He was the first physically and mentally healthy ruler of the Holy Roman Empire ever to be deposed without a papal excommunication. Adolf died shortly afterwards in the Battle of Göllheim fighting against his successor Albert of Habsburg. Albert I of Germany (July 1255 – 1 May 1308), the eldest son of King Rudolf I of Germany and his first wife Gertrude of Hohenberg, was a Duke of Austria and Styria from 1282 and King of Germany from 1298 until his assassination.

Albert was assassinated in 1308.

King Philip IV of France began aggressively seeking support for his brother, Charles of Valois, to be elected the next King of the Romans. Philip thought he had the backing of the French Pope Clement V (established at Avignon in 1309), and that his prospects of bringing the empire into the orbit of the French royal house were good. He lavishly spread French money in the hope of bribing the German electors. Although Charles of Valois had the backing of Henry, Archbishop of Cologne, a French supporter, many were not keen to see an expansion of French power, least of all Clement V. The principal rival to Charles appeared to be Rudolf, the Count Palatine.

Instead, Henry VII, of the House of Luxembourg, was elected with six votes at Frankfurt on 27 November 1308. Given his background, although he was a vassal of king Philip (King Philip IV of France), Henry was bound by few national ties, an aspect of his suitability as a compromise candidate among the electors, the great territorial magnates who had lived without a crowned emperor for decades, and who were unhappy with both Charles and Rudolf. Henry of Cologne's brother, Baldwin, Archbishop of Trier, won over a number of the electors, including Henry, in exchange for some substantial concessions. Henry VII was crowned king at Aachen on 6 January 1309, and emperor by Pope Clement V on 29 June 1312 in Rome, ending the interregnum.

The difficulties in electing the king eventually led to the emergence of a fixed college of prince-electors (Kurfürsten), whose composition and procedures were set forth in the Golden Bull of 1356, which remained valid until 1806. This development probably best symbolizes the emerging duality between emperor and realm (Kaiser und Reich), which were no longer considered identical. The Golden Bull also set forth the system for election of the Holy Roman Emperor. The emperor now was to be elected by a majority rather than by consent of all seven electors. For electors the title became hereditary, and they were given the right to mint coins and to exercise jurisdiction. Also it was recommended that their sons learn the imperial languages – German, Latin, Italian, and Czech.

The "constitution" of the Empire still remained largely unsettled at the beginning of the 15th century. Although some procedures and institutions had been fixed, for example by the Golden Bull of 1356, the rules of how the king, the electors, and the other dukes should cooperate in the Empire much depended on the personality of the respective king. It therefore proved somewhat damaging that Sigismund of Luxemburg (king 1410, emperor 1433–1437) and Frederick III of Habsburg (king 1440, emperor 1452–1493) neglected the old core lands of the empire and mostly resided in their own lands. Without the presence of the king, the old institution of the Hoftag, the assembly of the realm's leading men, deteriorated. The Imperial Diet as a legislative organ of the Empire did not exist at that time. The dukes often conducted feuds against each other – feuds that, more often than not, escalated into local wars.

The conflict between several papal claimants (two anti-popes and the "legitimate" Pope) ended only with the Council of Constance (1414–1418); after 1419 the Papacy directed much of its energy to suppressing the Hussites. The medieval idea of unifying all Christendom into a single political entity, with the Church and the Empire as its leading institutions, began to decline. The Council of Constance was a 15th-century ecumenical council recognized by the Catholic Church, held from 1414 to 1418 in the Bishopric of Constance in present-day Germany. The council ended the Western Schism by deposing or accepting the resignation of the remaining papal claimants and by electing Pope Martin V.

Frederick III (21 September 1415 – 19 August 1493) was Holy Roman Emperor from 1452 until his death. He was the first emperor of the House of Habsburg, and the fourth member of the House of Habsburg to be elected King of Germany after Rudolf I of Germany, Albert I in the 13th century and his predecessor Albert II of Germany. He was the penultimate emperor to be crowned by the Pope, and the last to be crowned in Rome.

When Frederick III needed the dukes to finance a war against Hungary in 1486, and at the same time had his son (later Maximilian I) elected king, he faced a demand from the united dukes for their participation in an Imperial Court. The Austrian–Hungarian War was a military conflict between the Kingdom of Hungary under Mathias Corvinus and the Habsburg Archduchy of Austria under Frederick V (also Holy Roman Emperor as Frederick III). The war lasted from 1477 to 1488 and resulted in significant gains for Matthias, which humiliated Frederick, but which were reversed upon Matthias' sudden death in 1490.

Ferdinand II (10 March 1452 – 23 January 1516), called the Catholic, was King of Aragon from 1479 until his death. In 1469, he married Infanta Isabella, the future queen of Castile, which was regarded as the marital and political "cornerstone in the foundation of the Spanish monarchy". As a consequence of the marriage, in 1474 he became de jure uxoris King of Castile as Ferdinand V, when Isabella held the crown of Castile, until her death in 1504. At Isabella's death the crown of Castile passed to their daughter Joanna, by the terms of their prenuptial agreement and Isabella‘s last will and testament, and Ferdinand lost his monarchical status in Castile. Joanna's husband Philip became de jure uxoris King of Castile, but died in 1506, and Joanna ruled in her own right. In 1504, after a war with France, he became King of Naples as Ferdinand III, reuniting Naples with Sicily permanently and for the first time since 1458. In 1506, as part of a treaty with a France, Ferdinand married Germaine of Foix of France, but Ferdinand's only son and child of that marriage died soon after birth. (Had the child survived, the personal union of the crowns of Aragon and Castile would have ceased.) In 1508, Ferdinand was recognized as regent of Castile, following Joanna's alleged mental illness, until his own death in 1516. In 1512, he became King of Navarre by conquest.

For the first time, the assembly of the electors and other dukes was now called the Imperial Diet (German Reichstag) (to be joined by the Imperial Free Cities later). While Frederick refused, his more conciliatory son (Maximilian I) finally convened the Diet at Worms in 1495, after his father's death in 1493.

In a decree following the 1512 Diet of Cologne, the name was changed to the "Holy Roman Empire of the German Nation", a form first used in a document in 1474. The new title was adopted partly because the Empire had lost most of its territories in Italy and Burgundy (the Kingdom of Arles) to the south and west by the late 15th century, but also to emphasize the new importance of the German Imperial Estates in ruling the Empire due to the Imperial Reform. By the end of the 18th century, the term "Holy Roman Empire of the German Nation" had fallen out of official use. Contradicting the traditional view concerning that designation, Hermann Weisert has argued in a study on imperial titulature that, despite the claims of many textbooks, the name "Holy Roman Empire of the German Nation" never had an official status and points out that documents were thirty times as likely to omit the national suffix as include it.

Here, the king and the dukes agreed on four bills, commonly referred to as the Reichsreform (Imperial Reform): a set of legal acts to give the disintegrating Empire some structure. For example, this act produced the Imperial Circle Estates and the Reichskammergericht (Imperial Chamber Court), institutions that would – to a degree – persist until the end of the Empire in 1806. It took a few more decades for the new regulation to gain universal acceptance and for the new court to begin functioning effectively; the Imperial Circles were finalized in 1512. The King also made sure that his own court, the Reichshofrat, continued to operate in parallel to the Reichskammergericht. Also in 1512, the Empire received its new title, the Heiliges Römisches Reich Deutscher Nation ("Holy Roman Empire of the German Nation").

In 1516, Ferdinand II of Aragon, grandfather of the future Holy Roman Emperor Charles V, died.

In addition to conflicts between his Spanish and German inheritances, conflicts of religion would be another source of tension during the reign of Charles V. Before Charles's reign in the Holy Roman Empire began, in 1517, Martin Luther launched what would later be known as the Reformation. At this time, many local dukes saw it as a chance to oppose the hegemony of Emperor Charles V. The empire then became fatally divided along religious lines, with the north, the east, and many of the major cities – Strasbourg, Frankfurt, and Nuremberg – becoming Protestant while the southern and western regions largely remained Catholic.

Charles V (24 February 1500 – 21 September 1558) was Holy Roman Emperor and Archduke of Austria from 1519, King of Spain (Castile and Aragon) from 1516, and Lord of the Netherlands as titular Duke of Burgundy from 1506. As head of the rising House of Habsburg during the first half of the 16th century, his dominions in Europe included the Holy Roman Empire, extending from Germany to northern Italy with direct rule over the Austrian hereditary lands and the Burgundian Low Countries, and a unified Spain with its southern Italian kingdoms of Naples, Sicily, and Sardinia. Furthermore, his reign encompassed both the long-lasting Spanish and short-lived German colonizations of the Americas. The personal union of the European and American territories of Charles V was the first collection of realms labelled "the empire on which the sun never sets".

Charles V continued to battle the French and the Protestant princes in Germany for much of his reign. After his son Philip II married Queen Mary of England, it appeared that France would be completely surrounded by Habsburg domains, but this hope proved unfounded when the marriage produced no children.

In 1555, Paul IV was elected pope and took the side of France, whereupon an exhausted Charles finally gave up his hopes of a world Christian empire. He abdicated and divided his territories between Philip and Ferdinand of Austria.

The Peace of Augsburg ended the war in Germany and accepted the existence of Protestantism in the form of Lutheranism, while Calvinism was still not recognized. Anabaptist, Arminian and other minor Protestant communities were also forbidden.

After Ferdinand I died in 1564, his son Maximilian II became Emperor, and like his father accepted the existence of Protestantism and the need for occasional compromise with it.

Maximilian was succeeded in 1576 by Rudolf II, a strange man who preferred classical Greek philosophy to Christianity and lived an isolated existence in Bohemia. He became afraid to act when the Catholic Church was forcibly reasserting control in Austria and Hungary, and the Protestant princes became upset over this. Imperial power sharply deteriorated by the time of Rudolf's death in 1612.

Germany would enjoy relative peace for the next six decades. On the eastern front, the Turks continued to loom large as a threat, although war would mean further compromises with the Protestant princes, and so the Emperor sought to avoid it. In the west, the Rhineland increasingly fell under French influence. After the Dutch revolt against Spain erupted, the Empire remained neutral, de facto allowing the Netherlands to depart the empire in 1581, a secession acknowledged in 1648. A side effect was the Cologne War, which ravaged much of the upper Rhine.

Matthias of Austria, a member of the House of Habsburg (February 24, 1557 - March 20, 1619) was Holy Roman Emperor and Archduke of Austria (1612 – 1619), king of Hungary (as Mátyás II) and Croatia (as Matija II) since 1608 and king of Bohemia (also as Matyáš II) since 1611. His personal motto was Concordia lumine maior ("Unity is stronger than light").

The Thirty Years' War was a war fought primarily in Central Europe between 1618 and 1648. One of the most destructive conflicts in human history, it resulted in eight million fatalities not only from military engagements but also from violence, famine, and plague. Casualties were overwhelmingly and disproportionately inhabitants of the Holy Roman Empire, most of the rest being battle deaths from various foreign armies. The deadly clashes ravaged Europe; 20 percent of the total population of Germany died during the conflict and there were losses up to 50 percent in a corridor between Pomerania and the Black Forest. In terms of proportional German casualties and destruction, it was surpassed only by the period of January to May 1945 during World War II. One of its enduring results was 19th-century Pan-Germanism, when it served as an example of the dangers of a divided Germany and became a key justification for the 1871 creation of the German Empire (although the German Empire excluded the German-speaking parts of the Austro-Hungarian Empire). When Bohemians rebelled against the Emperor, the immediate result was the series of conflicts known as the Thirty Years' War (1618–48), which devastated the Empire. Foreign powers, including France and Sweden, intervened in the conflict and strengthened those fighting Imperial power, but also seized considerable territory for themselves. The long conflict so bled the Empire that it never recovered its strength.

The actual end of the empire came in several steps. The Peace of Westphalia in 1648, which ended the Thirty Years' War, gave the territories almost complete independence. Calvinism was now allowed, but Anabaptists, Arminians and other Protestant communities would still lack any support and continue to be persecuted well until the end of the Empire. The Swiss Confederation, which had already established quasi-independence in 1499, as well as the Northern Netherlands, left the Empire. The Habsburg Emperors focused on consolidating their own estates in Austria and elsewhere. The treaties of Westphalia brought to an end a calamitous period of European history which caused the deaths of approximately eight million people. Scholars have identified Westphalia as the beginning of the modern international system, based on the concept of Westphalian sovereignty, though this interpretation has been challenged.

At the Battle of Vienna (1683), the Army of the Holy Roman Empire, led by the Polish King John III Sobieski, decisively defeated a large Turkish army, stopping the western Ottoman advance and leading to the eventual dismemberment of the Ottoman Empire in Europe. The army was half forces of the Polish–Lithuanian Commonwealth, mostly cavalry, and half forces of the Holy Roman Empire (German/Austrian), mostly infantry.

By the rise of Louis XIV, the Habsburgs were chiefly dependent on their hereditary lands to counter the rise of Prussia, some of whose territories lay inside the Empire. Throughout the 18th century, the Habsburgs were embroiled in various European conflicts, such as the War of the Spanish Succession, the War of the Polish Succession, and the War of the Austrian Succession. The German dualism between Austria and Prussia dominated the empire's history after 1740.

From 1792 onwards, revolutionary France was at war with various parts of the Empire intermittently.

The German mediatization was the series of mediatizations and secularizations that occurred between 1795 and 1814, during the latter part of the era of the French Revolution and then the Napoleonic Era. "Mediatization" was the process of annexing the lands of one imperial estate to another, often leaving the annexed some rights. For example, the estates of the Imperial Knights were formally mediatized in 1806, having de facto been seized by the great territorial states in 1803 in the so-called Rittersturm. "Secularization" was the abolition of the temporal power of an ecclesiastical ruler such as a bishop or an abbot and the annexation of the secularized territory to a secular territory.

The Battle of Austerlitz (2 December 1805/11 Frimaire An XIV FRC), also known as the Battle of the Three Emperors, was one of the most important and decisive engagements of the Napoleonic Wars. In what is widely regarded as the greatest victory achieved by Napoleon, the Grande Armée of France defeated a larger Russian and Austrian army led by Emperor Alexander I and Holy Roman Emperor Francis II. The battle occurred near the town of Austerlitz in the Austrian Empire (modern-day Slavkov u Brna in the Czech Republic). Austerlitz brought the War of the Third Coalition to a rapid end, with the Treaty of Pressburg signed by the Austrians later in the month. The battle is often cited as a tactical masterpiece, in the same league as other historic engagements like Cannae or Gaugamela.

The fourth Peace of Pressburg (also known as the Treaty of Pressburg) was signed on 27 December 1805 between Napoleon and Holy Roman Emperor Francis II as a consequence of the French victories over the Austrians at Ulm (25 September – 20 October) and Austerlitz (2 December). A truce was agreed on 4 December, and negotiations for the treaty began. The treaty was signed in Pressburg (today's Bratislava), Hungary, by Johann I Josef, Prince of Liechtenstein, and the Hungarian Count Ignác Gyulay for the Austrian Empire and Charles Maurice de Talleyrand for France.

Napoleon reorganized much of the Empire into the Confederation of the Rhine, a French satellite. Francis' House of Habsburg-Lorraine survived the demise of the empire, continuing to reign as Emperors of Austria and Kings of Hungary until the Habsburg empire's final dissolution in 1918 in the aftermath of World War I. The Confederation of the Rhine ("Confederated States of the Rhine") was a confederation of client states of the First French Empire. It was formed initially from sixteen German states by Napoleon after he defeated Austria and Russia at the Battle of Austerlitz. The Treaty of Pressburg, in effect, led to the creation of the Confederation of the Rhine, which lasted from 1806 to 1813.

The empire was dissolved on 6 August 1806, when the last Holy Roman Emperor Francis II (from 1804, Emperor Francis I of Austria) abdicated, following a military defeat by the French under Napoleon at Austerlitz.

The Napoleonic Confederation of the Rhine was replaced by a new union, the German Confederation, in 1815, following the end of the Napoleonic Wars. The German Confederation was an association of 39 German-speaking states in Central Europe (adding the mainly non-German speaking Kingdom of Bohemia and Duchy of Carniola), created by the Congress of Vienna in 1815 to coordinate the economies of separate German-speaking countries and to replace the former Holy Roman Empire, which had been dissolved in 1806. The German Confederation excluded German-speaking lands in the eastern portion of the Kingdom of Prussia (East Prussia, West Prussia and Posen), the German cantons of Switzerland, and the French region of Alsace, which was predominantly German speaking.

German Confederation lasted until 1866 when Prussia founded the North German Confederation, a forerunner of the German Empire which united the German-speaking territories outside of Austria and Switzerland under Prussian leadership in 1871. This state developed into modern Germany. The North German Confederation was the German federal state which existed from July 1867 to December 1870. Although de jure a confederacy of equal states, the Confederation was de facto controlled and led by the largest and most powerful member, Prussia, which exercised its influence to bring about the formation of the German Empire. Some historians also use the name for the alliance of 22 German states formed on 18 August 1866 (Augustbündnis). In 1870–1871, the south German states of Baden, Hesse-Darmstadt, Württemberg and Bavaria joined the country. On 1 January 1871, the country adopted a new constitution, which was written under the title of a new "German Confederation" but already gave it the name "German Empire" in the preamble and article 11. The only princely member state of the Holy Roman Empire that has preserved its status as a monarchy until today is the Principality of Liechtenstein. The only Free Imperial Cities still being states within Germany are Hamburg and Bremen. All other historic member states of the HRE were either dissolved or are republican successor states to their princely predecessor states.

In the modern period, the Empire was often informally called the German Empire (Deutsches Reich) or Roman-German Empire (Römisch-Deutsches Reich). After its dissolution through the end of the German Empire, it was often called "the old Empire" (das alte Reich). Beginning in 1923, early-twentieth century German nationalists and Nazi propaganda would identify the Holy Roman Empire as the First Reich (Reich meaning empire), with the German Empire as the Second Reich and either a future German nationalist state or Nazi Germany as the Third Reich.