From the middle of the 17th century, the nobles' democracy, suffering from internal disorder, gradually declined, thereby leaving the once powerful Commonwealth vulnerable. The Polish and Catholic domination of present-day Ukraine resulted in the 1648 Khmelnytsky Uprising, which engulfed much of the eastern parts of the country and led to the creation of a Ukrainian Cossack state allied with Russia. This was followed by the Swedish Deluge during the Second Northern War, which marched through the Polish heartlands and decimated the country's population and infrastructure. Finding itself subjected to almost constant warfare, the Commonwealth fell into decline, further weakened when Prussia declared independence in 1657. The government became ineffective as a result of internal conflicts, rebellious confederations and corrupted legislative processes. However, under John III Sobieski the Commonwealth's military prowess was re-established, and in 1683 Polish forces played a major role in the Battle of Vienna against the Ottoman Army.