The Old Swiss Confederacy began as an alliance between the communities of the valleys in the Central Alps, at the time part of the Holy Roman Empire, to facilitate the management of common interests such as free trade and to ensure the peace along the important trade routes through the mountains.
The Hohenstaufen emperors had granted these valleys reichsfrei status in the early 13th century. As reichsfrei regions, the cantons (or regions) of Uri, Schwyz, and Unterwalden were under the direct authority of the emperor without any intermediate liege lords and thus were largely autonomous.
With the rise of the Habsburg dynasty, the kings and dukes of Habsburg sought to extend their influence over this region and to bring it under their rule; as a consequence, a conflict ensued between the Habsburgs and these mountain communities who tried to defend their privileged status as reichsfrei regions.
The three founding cantons of the Schweizerische Eidgenossenschaft, as the confederacy was called, were joined in the early 14th century by the city states of Lucerne, Zürich, and Bern, and they managed to defeat Habsburg armies on several occasions. They also profited from the fact that the emperors of the Holy Roman Empire, for most of the 14th century, came from the House of Luxembourg and regarded them as potential useful allies against the rival Habsburgs.