and the Saxon-led coalition army was defeated in 1706 at the Battle of Fraustadt. As a result of the favorable for him outcomes at the War of the Spanish Succession, Charles XII was able to enter the Holy Roman Empire and occupied Saxony. Augustus II had to agree to humiliating terms of the Treaty of Altranstädt of 1706, in which he renounced the Polish crown. Prior to the treaty ratification, Augustus still managed to defeat at Kalisz a combined Swedish and Warsaw Confederation force, which left most of the Commonwealth clear of the Swedish occupiers, until Charles entered through Silesia again. The Sandomierz Confederation held to their alliance with Peter I of Russia also during the Charles' Moscow offensive, when the Russian troops left Poland. Stanisław Leszczyński's forces, charged with protecting the rear end, were defeated by his and Charles' Polish adversaries at the Battle of Koniecpol. Stanisław and von Krassow (commander of the Swedish units left in Poland), thwarted by the Sandomierz confederates again, were unable to break through to join Charles who was stuck in Ukraine, where the Cossack hetman Ivan Mazepa largely failed to deliver on his promised support for the Swedes. The Swedish supply train approaching from Livonia was destroyed by the Russians, and thus the actions of the Sandomierz Confederation alliance significantly contributed to Charles' ultimate failure at the Battle of Poltava in 1709. After Poltava von Krassow and his forces withdrew to Swedish Pomerania and the rule of Augustus II was restored, as Leszczyński sought refuge in Swedish-controlled Stettin. Charles XII found his in Bender, under the Ottoman rule, and was still a cause of unrest in the Commonwealth. The Russo-Turkish War (1710–11), instigated by Charles, ended in the defeat of Tsar Peter, who was obliged to remove his forces from the Commonwealth. Augustus' expeditions into Western Pomerania in 1711–13 with the Danes and Russians resulted only in the Prussian takeover of Stettin. Under the circumstances Augustus wanted to terminate his participation in the war and free himself from his dependence on Peter I, previously formalized under the Treaty of Thorn of 1709, but achieved only a partial success. Attempts at peace with Sweden, which would strengthen Augustus' hand in dealing with Peter, turned also elusive, as Charles XII kept making excessive demands, including high reparations for Leszczyński. Resumption of hostilities necessarily followed, because Charles, having returned from his exile, embarked on building of