During the Thirty Years' War (1618β1648), Switzerland managed to remain neutral despite deep religious divisions between Catholic and Protestant cantons. This neutrality was maintained through strategic diplomacy, as both Catholic and Protestant cantons secured mercenary contracts with various European powers, ensuring no single foreign faction could dominate the region. Key alpine passes remained closed to military movements, safeguarding Swiss independence.
While the Swiss Confederacy avoided direct involvement in the conflict, the Grisons (Three Leagues) were drawn into the war. The strategically important Valtellina, a subject territory of the Grisons, was seized by Spain in 1620, triggering years of unrest known as the Confusion of the Leagues. Although France briefly intervened in the Grisons, Spain and Austria reasserted control, re-Catholicizing parts of the region. By 1639, the Grisons regained their territories, though the Valtellina remained Catholic.
Switzerland's neutrality and de facto independence were formally recognized in the Treaty of Westphalia in 1648, marking its official separation from the Holy Roman Empire. This diplomatic victory ensured Swiss sovereignty and laid the foundation for the confederacy's policy of neutrality in European conflicts going forward.