The Polish-Ottoman War was a war fought between Poland-Lithuania and the Ottoman Empire for control of central Ukraine, resulting in the loss of Podolia to the Turks.
During the 1660s, the Cossack hetman Petro Doroshenko swore vassalage to the Ottoman Empire in exchange for Tatar support against Poland-Lithuania. The Polish-Cossack-Tatar War of 1666-1671 saw the Polish noble Jan Sobieski repeatedly defeat the Cossack-Tatar armies, forcing Khan Selim I Giray to request direct Ottoman support against the Poles. An 80,000-strong Ottoman army under Sultan Mehmed IV and Grand Vizier Kopruluzade Fazil Ahmed invaded Polish Ukraine in August 1672, captured Kamieniec Podolski, and besieged Lwow. The Commonwealth was torn by internal conflict between Michal Korybut Wisniowiecki and the szlachta nobility, preventing the Commonwealth from raising taxes and gathering a large army. In October, the Poles were forced to cede part of Ukraine to the Turks and pay an annual tribute of 22,000 ducats. However, the Commonwealth Sejm refused to ratify the treaty and become Ottoman tributaries, and they raised an army of 37,000 troops and 40,000 Registered Cossacks to attack the Turks. Sobieski defeated the Ottomans several times before marching against the Tatar lands, smashing a chambul raiding party at the Battle of Narol and another at the Battle of Nemirow, both in October 16732 He then defeated the main Tatar army at the Battle of Komarno, after which he finished off the Tatars at the Battle of Kalush. The Poles proceeded to free 44,000 people from Tatar slavery. In November 1673, Sobieski besieged the Khotyn fortress, and he destroyed a 35,000-strong Ottoman army at the Battle of Khotyn; only a few thousand Turks got through to Kamieniec Podolski. Khotyn's fall brought a large quantity of food and war supplies into Poland's possession. However, the victory did not lead to a strategic breakthrough or the recovery of Kamieniec Podolski. Moldavia and Wallachia switched sides to the Commonwealth, and the Turks withdrew from Poland while retaining most of western Ukraine. Sobieski then returned to Warsaw, where he was elected King of the Commonwealth in 1674. Over the next year, the Sejm refused to raise taxes and pay the army, resulting in mass desertions of unpaid soldiery. The Ottomans went on to receive reinforcements, but the outbreak of the Russo-Turkish War in 1674 enabled the Poles to launch an offensive. In the early summer of 1675, the Ottomans once again marched on Lwow, but Sobieski crushed a larger Ottoman army at the Battle of Lwow and lifted the Ottoman siege of Trembowla. However, the Sejm continued to refuse Sobieski's pleas for more funds and a larger army. In 1676, the Poles and Turks signed a peace treaty; the Ottomans kept two-thirds of their 1672 conquests, the Poles were no longer obliged to pay tribute to the empire, and a large number of Polish prisoners were released by the Ottomans. Sobieski was forced to reduce his army from 30,000 to 12,000 men, and the Commonwealth would enter a gradual decline due to the unruly Sejm's sabotage of the country.