Switzerland is a federation of relatively autonomous cantons, some of which have a history of confederacy that goes back more than 700 years, arguably putting them among the world's oldest surviving republics.
According to the popular legend, in 1291, representatives of the three forest cantons of Uri, Schwyz, and Unterwalden signed the Federal Charter. The charter united the involved parties in the struggle against foreign rule by the Habsburgs, who then held the German imperial throne of the Holy Roman Empire. At the Battle of Morgarten in 1315, the Swiss defeated the Habsburg army and secured quasi-independence as the Swiss Confederation. The authenticity of the Federal Charter is disputed with many historians agreeing that it is in fact a forgery of the 14th century.
By 1353, the three original cantons had been joined by the cantons of Glarus and Zug and the city states of Lucerne, Zürich and Berne, forming the "Old Federation" of eight states that persisted during much of the 15th century (although Zürich was expelled from the confederation during the 1440s due to a territorial conflict) and led to a significant increase of power and wealth of the federation, in particular due to the victories over Charles the Bold of Burgundy during the 1470s, and the success of the Swiss mercenaries. The Swiss victory in a war against the Swabian League in 1499 amounted to de facto independence from the Holy Roman Empire.
The expansion of the federation, and the reputation of invincibility acquired during the earlier wars, suffered a first setback in 1515 with the Swiss defeat in the Battle of Marignano. The success of Zwingli's Reformation in some cantons led to inter-cantonal wars in 1529 and 1531 (Kappeler Kriege). The conflict between Catholic and Protestant cantons persisted, erupting in further violence at the battles of Villmergen in 1656 and 1712.
Switzerland proclaimed neutrality in World War I and was not involved militarily in the conflict. Neutrality was again proclaimed in World War II, and although a German intervention was both planned and anticipated, it ultimately didn't occur. The massive mobilization of Swiss armed forces under the leadership of General Henri Guisan is often cited as a decisive factor that the German invasion was never initiated. Modern historical findings, such as the research done by the Bergier commission, indicate that another major factor was the continued trade by Swiss banks with Nazi Germany.
Women were granted the right to vote in the first cantons in 1959, at the federal level in 1971, in the last canton only in 1990. In 1979, parts of the canton of Berne attained independence, forming the new canton of Jura. On April 18, 1999 the Swiss population and the cantons voted in favor of a completely revised federal constitution.
In 2002 Switzerland became a full member of the United Nations, leaving the Vatican as the last widely recognized state without full UN membership. Switzerland is not a member state of the EU but applied for membership therein in May 1992. Switzerland has not advanced this application since the rejection, by referendum, of the European Economic Area in December 1992. However, Swiss law is gradually being adjusted to that of the EU and the government has signed a number of bilateral agreements with the European Union. Switzerland (together with Liechtenstein) has been surrounded by the EU since Austria's membership in 1995. On June 5, 2005, Swiss voters agreed, by a 55% majority, to join the Schengen treaty, a result that was welcomed by EU commentators as a sign of goodwill by a Switzerland that is traditionally perceived as isolationist.