During the Early Middle Ages (8th–10th centuries), Austria’s territory was part of the Duchy of Bavaria, a region that shifted between independence and control by the Frankish Empire. Initially, the Bavarians achieved brief independence by 717 CE, but were soon subdued by Charles Martel. In 788 CE, Charlemagne deposed the last Agilolfing duke, Tassilo III, bringing Bavaria and its territories under direct Carolingian control.
Charlemagne’s campaigns against the Avars in 791–803 CE expanded Frankish influence eastward. The Avars retreated beyond the Fischa and Leitha rivers, allowing Charlemagne to establish defensive marches (military borderlands) from the Danube to the Adriatic Sea. Among these was the Avar March, located in what is now Lower Austria, and the March of Carinthia to the south. Both became part of the Marcha orientalis (Eastern March), a frontier region of Bavaria.
By 805 CE, with Charlemagne’s permission, the remaining Avars settled southeast of Vienna. However, a new threat emerged in 862 CE with the arrival of the Magyars, who had migrated westward after being displaced from the steppes. By 896 CE, they occupied the Hungarian Plain and began frequent raids into Bavarian and Frankish territories. In 907 CE, the Hungarians dealt a decisive defeat to the Bavarians at the Battle of Pressburg, forcing them to retreat to the Enns River by 909 CE.
Bavaria became a margraviate under Engeldeo (890–895) and was briefly reunited with Carinthia under Arnulf the Bad (907–937). However, his son Eberhard was deposed by Otto I (the future Holy Roman Emperor) in 938 CE. Under Otto I’s leadership, the Hungarians were defeated at the Battle of Lechfeld in 955, ending their raids and beginning the gradual reconquest of eastern territories, including Istria and Carniola.
Otto I reorganized his empire, reducing Bavaria’s size by re-establishing the Duchy of Carinthia. To the east, he created a new Eastern March (Ostmark), which would later become Austria. In 976 CE, Otto I appointed Leopold I of the Babenberg dynasty to rule this new march. Leopold, known as Leopold the Illustrious, governed from 976 to 994 CE, laying the foundation for what would eventually evolve into the Austrian state.