Opponents of Augustus II formed the Warsaw Confederation, and on February 16, 1704 in Warsaw, they dethroned him. In April of the same year, young Voivode of Poznań, Stanisław Leszczyński, met with King Charles XII of Sweden in Lidzbark Warmiński. The Swedish monarch, aware of Leszczyński’s influences in Greater Poland, declared that he should be new King of Poland–Lithuania. Leszczyński initially pledged that he would temporarily control the crown, to hand it over to James Louis Sobieski, but never kept his promise.
On July 12, 1704, a small group of szlachta, gathered in a Swedish army camp near Warsaw, declared Leszczyński the new King. The election was not confirmed by Primate Radziejowski, but by Bishop of Poznań Mikołaj Święcicki, which was against the rules. On October 4, 1704, Leszczyński was crowned by Archbishop of Lwów, Konstanty Józef Zieliński. The coronation took place at Warsaw’s St. John's Archcathedral.
Augustus II, however, did not give up Polish crown and did not abdicate. In May 1704, he formed the anti-Swedish Sandomierz Confederation, called for the levee en masse, and on August 30, signed the Treaty of Narva, establishing the Polish - Russian alliance, and officially declaring war between the Commonwealth and Sweden. This decision resulted in a civil war in Poland - Lithuania, between supporters of Augustus and Leszczyński. Initially, Augustus managed to recapture Warsaw, and win the support of most senators, during a council in Grodno. On February 13, 1706, however, Augustus lost the Battle of Fraustadt, and, facing Swedish occupation of Saxony, gave up his claim to Polish crown in the Treaty of Altranstadt (1706).
Augustus retook Polish throne in 1709, after Swedish defeat in the Battle of Poltava. In revenge, Russian troops, stationed in Poland, burned and ransacked the city of Leszno, which was property of the Leszczyński family.