rewarded in the end with the Duchy of Prussia, possibly also some acquisitions in Silesia. The French-Polish intentions were to be thwarted by both the international and Commonwealth internal obstacles. Austria and Brandenburg in turn provided funds for the King's rivals to tie his hands. Vienna and Moscow signed their own treaty against Sobieski's policies, in which for the first time the external powers pledged to defend szlachta's "liberties", the guarantees of the Commonwealth's weakness. Most importantly the Swedes failed in their military endeavors. Coming from the west in Pomerania the Swedish forces were defeated and Frederick William took Stettin again. The attempt to take over the Duchy of Prussia fell likewise. In 1677, a secret Polish–Swedish understanding was signed in Danzig, according to which John III agreed to let the Swedes pass through Livonia into Prussia, in addition to strengthening them with his own forces. The Swedish intervention became badly delayed and ended in another defeat. Only Louis XIV's diplomatic activities prevented the Swedes from losing Stettin. In addition to conducting this last assertive Commonwealth attempt in the Baltic area, John III for a time was also involved in anti-Habsburg diversion in Hungary, engulfed by the Kuruc uprising led by Imre Thököly. The Hungarian rebels were helped with volunteers and supply, and in 1677 with a military expedition led into Hungary by Hieronim Lubomirski. As the King failed to convince the nobility of the necessity of action in the north, the country's establishment directed its attention back toward the recovery of the lands lost in the east. Russia however was now seen as an ally against the Ottoman power. In order to reclaim the areas lost to Turkey in the south-east and to reestablish influence in Moldavia, John III sought to build a grand European anti-Ottoman league. While his ideas met with cool reception in most European centers of power, except for the papacy and Vienna, Turkey's own military undertakings worked in favor of Sobieski's plans. Mehmed IV, having concluded in 1681 the war with Russia, was getting ready to take up the defense of Thököly and move against Austria. Facing a choice of leaving the Habsburg state to its own fate or forming with it a coalition to defeat the Ottoman invaders, Sobieski chose the second option, distancing himself from and acting internally against the pro-French camp. The limited mutual defense alliance with Austria was approved in the