But back in 745 AD, the Carantanians sought military assistance due to the pressing danger coming from the Avar tribes from the east and accepted a union with the Bavarians. They gradually converted to Christianity and later lost their independence by becoming part of the Frankish Empire under the rule of Charlemagne. After the battle of Lechfeld in 955 AD, when the Magyars were defeated, Carantania became part of the Holy Roman Empire.
From 1335 to 1918, the Slovenian regions were governed by the Habsburgs, later the Austro-Hungarian Monarchy, except for a brief five-year period during the Napoleonic Wars when France ruled over them.