In early 1700, King of Poland, Grand Duke of Lithuania and Elector of Saxony, Augustus II the Strong began the Great Northern War by attacking Swedish Livonia. Despite Russian support, Saxon army lost several battles, and soon afterwards, forces of the Swedish Empire controlled most of the Polish-Lithuanian Commonwealth. In June 1703, Augustus II convened the Extraordinary Sejm in Lublin, where he faced widespread criticism. His opponent were led by Primate of Poland, Michał Radziejowski, and sons of late King Jan III Sobieski, Jakub and Konstanty.
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. Swedish monarch, aware of Leszczynski’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 Leszczynski 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 Leszczynski. 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.