 In the effect of the Treaty of Buchach of 1672 the town was ceded to Ottoman Empire, but it returned to Poland after the Treaty of Karlowitz of 1699.Following the Partitions of Poland it became part of Austrian Empire and was then seized by Napoleon Bonaparte who gave it to Russian Empire in the Treaty of Tilsit of 1807.Russian control however ended with the Congress of Vienna which awarded the area back to Austria.