sentences:  The defeat of Ottoman forces led by Grand Vizier Kara Mustafa Pasha at the Second Siege of Vienna in 1683, at the hands of the combined armies of Poland and the Holy Roman Empire under John III Sobieski, was the decisive event that swung the balance of power in the region.Under the terms of the Treaty of Karlowitz, which ended the Great Turkish War in 1699, the Ottomans ceded to Habsburgs much of the territory they had previously taken from the medieval Kingdom of Hungary.Following this treaty, the members of the Habsburg dynasty administered a much enlarged Habsburg Kingdom of Hungary (previously they controlled only area known as "Royal Hungary"; see Kingdom of Hungary (1526–1867)).