The Holy Roman Emperor was, with some variation, the ruler of the Holy Roman Empire, the predecessor of modern Germany, during its existence from the 10th century until its collapse in 1806.
The terminology of the title is somewhat confusing. The title of "emperor" was considered to have passed from the Romans to the Frankish kingdom when, in 800 AD, Pope Leo III crowned Charlemagne, king of the Franks, emperor in exchange for the protection of the church. After the division of the Frankish realm into three parts by the Treaty of Verdun in 843, the title first remained in the middle Lotharingian realm, but eventually passed to the east when Otto I the Great, king of the East Franks, was crowned emperor in 962. The transfer of the Empire was, in medieval theory, referred to as translatio imperii.
Initially, the emperor called himself Imperator Augustus, referring to Roman Emperor Augustus. The title of "Holy Roman Emperor", as the name of the Holy Roman Empire itself, was only used in later centuries.
Until 1508, the king of the Germans, who was elected by a group of dukes later known as electors, became emperor when he was crowned by the pope in Rome, after which he remained king (a title with functions in feudal law). By contrast, the title of emperor had a more religious connotation, suggesting the task of protecting the church. The exact relationship between the two functions was never entirely clear and lead to much conflict between the German dukes and the pope, for example in the Investiture Controversy in the 11th century.
The selection of the king was influenced by a complicated mélange of factors. Formally elected, as opposed to France, the title was only to a degree hereditary, although it frequently remained in a dynasty until there were no more successors. Some scholars suggest that the task of the electors was really to solve succession conflicts, when the dynastic rule was unclear. Still, the process required the most probable candidate to make concessions to the voters, the so-called Wahlkapitulationen (election capitulations), which contributed to the decline of central power in favor of the territories in the Empire. The collegiate of electors was fixed to seven in the Golden Bull in 1356 until 1623, when, during the Thirty Years' War, more electors were added.
After 1438, the kingdom remained in the house of Habsburg, with only one brief exception. From 1508, after his election, the king no longer called for the coronation of the pope either, but considered himself emperor directly.
When the Empire collapsed in 1806 at the behest of Napoleon, Emperor Francis II called himself emperor of Austria instead. The exclusivity of the title in Europe was lost when Napoleon called himself Emperor too; after the formation of the 1871 German Empire, the Prussian king had himself crowned Emperor again, in competition with the one in Austria.