Schweizerkrieg in Germany) broke out in 1499, opposing the confederation against the Swabian League and emperor Maximilian I. After some battles around Schaffhausen, in the Austrian Vorarlberg and in the Grisons, where the confederates were victorious more often than not, the Battle of Dornach, where the emperor's commander was killed, put an end to the war. In September 1499, a peace agreement was concluded at Basel that effectively established a de facto independence of the Eidgenossenschaft from the empire, although it continued nominally to be part of the Holy Roman Empire until after the Thirty Years' War and was not included into the system of Imperial Circles in 1500. As a direct consequence of the Swabian War the previously associated city states of Basel and Schaffhausen joined the confederation in 1501. In 1513, the Appenzell followed suit as the thirteenth member. The cities of St. Gallen, Biel, Mulhouse and Rottweil as well as the Three Leagues in the Grisons were all associates of the confederation (Zugewandte Orte); the Valais would become an associate state in 1529. Annexation of the Ticino and the Veltlin The Ticino region consisted of several city-states along the Ticino river. Following the conquest of the region, it was divided into four Ticino Bailiwicks which were under the joint administration of the 13 Cantons after 1512. The four bailiwicks were Valle di Maggia (), Locarno (), Lugano () and Mendrisio (). The area also included several other territories that were owned by one or more cantons. These included: the Bailiwick of Bellinzona (), Blenio () and Riviera () which were owned by Uri, Schwyz, and Nidwalden as well as the bailiwick Leventina () (owned by Uri) and even the Val d'Ossola (). There were also three Italian-speaking subjects areas of the Three Leagues (Bormio, Valtellina and Chiavenna) which were not included in the Ticino Bailiwicks. Between 1403 and 1422 some of these lands were annexed by forces from Uri, but subsequently lost after the Battle of Arbedo in 1422. While the Battle of Arbedo stopped Swiss expansion for a time, the Confederation continued to exercise influence in the area. The Canton of Uri conquered the Leventina Valley in 1440. In a second conquest Uri, Schwyz and Nidwalden gained the town of Bellinzona and the Riviera in 1500. The third conquest was fought by troops from the entire Confederation (at that time constituted by 12 cantons). In 1512,