Although King John Casimir of Poland tried to limit the restrictions on their religious freedoms and the erosion of their ancient rights and privileges, the gentry opposed. Finally, in 1672, during the war with the Ottomans, the Lipka Tatar regiments (numbering up to 3,000 men) stationed in the Podolia region of south-east Poland abandoned the Commonwealth at the start of the Polish-Turkish wars that were to last to end of the 17th century with the Peace of Karłowice in 1699. Although the Lipkas initially fought for the victorious Turks, soon their camp was divided onto the supporters of the Turks and a large part of Tatars dissatisfied with the Ottoman rule. Although after the treaty of Buczacz the Tatars were granted lands around the fortresses of Bar and Kamieniec Podolski, the liberties enjoyed by their community within the Ottoman Empire were much less than those within the Commonwealth. Finally, in 1674, after the Polish victory at Chocim, the Lipka Tatars who held the Podolia for Turkey from the stronghold of Bar were besieged by the armies of Jan Sobieski, and a deal was struck that the Lipkas would return to the Polish side subject to their ancient rights and privileges being restored. All the Tatars were pardoned by Sobieski and most of them took part in his campaign against Turkey resulting in the brilliant victory in the battle of Vienna. The Lipka Rebellion forms the background to the novel "Fire in the Steppe (Pan Wołodyjowski)", the final volume of the Nobel Prize-winning historical "Trylogia" of Henryk Sienkiewicz. The 1969 film adaptation "Colonel Wolodyjowski", directed by Jerzy Hoffman and starring Daniel Olbrychski as Azja Tuhaj-bejowicz, was one of the largest box-office success in the history of Polish cinema.