Ieremia Movilă died in 1606 . In 1607 Stefan Potocki set his brother-in-law , Constantin Movilă , on the Moldavian throne. However, Stefan Potocki was one of the pro-Habsburg magnates and Gabriel Batory, the anti-Habsburg ruler of Transylvania, removed Constantin Movilă in 1611 . The Moldavian throne now fell to Ștefan II Tomșa . A second intervention by Stefan Potocki  in 1612 was a complete failure. Potocki's 7,000 strong army was defeated on 19 July in the Battle of Sasowy Róg  by troops of Tomșa and Khan Temir's Tatars of the Budjak Horde. Stefan Potocki and Constantin Movilă ended their lives in Ottoman captivity in Constantinople. A counter-raid of Tatars and Tomșa on the Commonwealth was stopped by Żółkiewski without a fight, and an agreement between Żółkiewski and Tomșa was signed in October 1612 . Tomșa assured about his friendliness, that he will help to patch up conflict between the Ottoman Empire and the Commonwealth and pledged allegiance to the Polish king. In 1613, when Sigismund signed a de facto anti-Turkish defensive treaty with the Habsburgs, counting on their support for his restoration to the Swedish throne, Poland further moved into the enemy camp from the Ottoman point of view. Hetman Stanisław Żółkiewski, with a show of force, induced Moldavians and Turks to compromise and signed an agreement in 1612 with Ștefan Tomșa at Khotyn.. Who removed Constantin Movilă from the throne, Stefan Potocki or Gabriel Batory?