Swedish successes led to a growing number of Polish-Lithuanian magnates switching sides, culminating in the formation of Warsaw Confederation on 16 February 1704 and the election of Swedish-endorsed voivode of Poznań, Stanisław I, as the new Polish king on 12 July 1704. Augustus the Strong still enjoyed support of a Polish faction, the Sandomierz Confederation, and about 75% of the Polish army. Augustus and his supporters declared war on Sweden, and joined the anti-Swedish Russian coalition at Narva on 30 August 1704. By October 1703 Augustus had to abandon Warsaw. A Russo-Saxo-Polish-Lithuanian army was then assembled at Polotsk, another allied army in Saxony, and a third allied force commanded by General Otto Arnold von Paykull advanced towards Warsaw, where Charles XII and Stanisław sojourned. Pajkul's Saxo-Polish-Lithuanian forces reached the outskirts of Warsaw on 31 July 1705, where they were defeated. The army at Polotsk was denied westward advance by Swedish forces under Adam Ludwig Lewenhaupt. Thus, Stanisław was crowned king of Poland in Warsaw on 4 October 1705 soon afterward he and his supporters concluded an alliance with the Swedish Empire in the Treaty of Warsaw in November 1705. Augustus was not done yet. In early 1706 he approached Warsaw with a cavalry force and ordered Johann Matthias von der Schulenburg to move the army assembled in Saxony into Poland-Lithuania. Schulenburg was intercepted and defeated by Carl Gustav Rehnskiöld in the Battle of Fraustadt on 13 February 1706. The army assembled in Polotsk had been moved to Grodno where it was tactically defeated and forced to withdraw eastwards around the same time. Charles XII then occupied Saxony, forcing Augustus to abandon both the Polish crown and his allies in the Treaty of Altranstädt on 13 October 1706 in which Augustus was forced to give up his claims to the Polish crown.
Aftermath
Stanisław's reign was short; in 1709 the Russians decisive victory at the Battle of Poltava undermined his position in Poland. Soon after the Swedish defeat Stanisław I abandoned Poland, and Augustus resumed his position as the Polish king. Augustus position was backed up by the Russians, who would assume an increasingly dominating role in Polish internal politics following this conflict.
The civil war, together with a later War of the Polish Succession in which Leszczyński challenged Augustus' son, was immortalized in a Polish saying "Jedni do Sasa, drudzy do Lasa", denoting a state of division, disorder and anarchy. Another variant of the saying is "Od Sasa do Lasa".