However, when the Empire lost the war of 1683–1697 with Austria, and ceded Slavonia and Hungary to Austria at the Treaty of Karlowitz, Bosnia's northern and western borders became the frontier between the Austrian and Ottoman empires.