Called Helvetia in ancient times, Switzerland in 1291 was a league of cantons in the Holy Roman Empire. Fashioned around the nucleus of three German forest districts of Schwyz, Uri, and Unterwalden, the Swiss Confederation slowly added new cantons. In 1648 the Treaty of Westphalia gave Switzerland its independence from the Holy Roman Empire.
French revolutionary troops occupied the country in 1798 and named it the Helvetic Republic, but Napoléon in 1803 restored its federal government. By 1815, the French- and Italian-speaking peoples of Switzerland had been granted political equality.
In 1815, the Congress of Vienna guaranteed the neutrality and recognized the independence of Switzerland. In the revolutionary period of 1847, the Catholic cantons seceded and organized a separate union called the Sonderbund , but they were defeated and rejoined the federation.