hold off the enemy along the line of the San River was unsuccessful, as his forces were trapped by Czarniecki, Jerzy Lubomirski and Sapieha at the fork formed by the San with the Vistula. When Czarniecki left the site to face and crush at Warka the approaching Swedish rescue force under Margrave Friedrich of Baden, Charles Gustav was able to escape the predicament, but the massive Polish uprising by then seized the initiative and broke the Swedish defenses. Most of Lesser Poland was liberated, except for Kraków, and Greater Poland was also cleared of the Swedes following Czarniecki's and Lubomirski's raid there. At the end of June Warsaw, defended by Wittenberg, was stormed and retaken by the popular forces. Seeking help the Swedish king made Frederick William an offer of Greater Poland. The combined armies of the two monarchs approached Warsaw and fought at the end of July a three-day heavy battle against Polish and Lithuanian troops aided by the Tatars, won by the Swedish-Brandenburg coalition. Frederick William however soon had to retreat after his duchy was attacked by Polish and Tatar forces. Hetman Gosiewski managed to defeat the combined enemy at the Battle of Prostki, while Czarniecki conducted further clearing activities in Greater Poland followed by a revenge incursion into the Brandenburg March and Farther Pomerania. The international balance of power was also shifting in favor of the Commonwealth because of the agreement with Russia in fall of 1656, motivated in part by the Tsardom's strategic interest in preventing a collapse of the Polish–Lithuanian state and uncontrolled expansion of Sweden. Not giving up its own claims and gains in the east, Russia moved against the Swedish forces in Livonia, which also facilitated their removal from Lithuania. This new situation forced Charles Gustav to alter his plans of conquering all of Poland and to propose a territorial partitioning scheme, under which the Polish–Lithuanian Commonwealth was to be eliminated altogether and he would be able to keep at least some of Sweden's prospects. First in the Treaty of Labiau the Swedish king granted sovereign rights in Prussia and possession of Greater Poland to Frederick William. In December 1656 a partition treaty involving several monarchs and other parties was concluded in Radnot in Transylvania. One of the treaty signatories was George II Rákóczi, Prince of Transylvania, whose forces entered the Commonwealth in early 1657 on a pillaging spree, reaching in cooperation with