Polish–Lithuanian royal election, 1704

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, Michal 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 Poznan, Stanislaw Leszczynski, met with King Charles XII of Sweden in Lidzbark Warminski. Swedish monarch, aware of Leszczynski’s influences in Greater Poland, declared that he should be new King of Poland - Lithuania. Leszczynski 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 Poznan Mikolaj Swiecicki, which was against the rules. On October 4, 1704, Leszczynski was crowned by Archbishop of Lwow, Konstanty Jozef Zielinski. 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 Leszczynski family.