The Ottoman Empire began its expansion into Europe by taking the European portions of the Byzantine Empire in the 14th and 15th centuries up until the 1453 capture of Constantinople, establishing Islam as the state religion in the region. The Ottoman Empire continued to stretch northwards, taking Hungary in the 16th century, and reaching as far north as the Podolia in the mid-17th century (Peace of Buczacz), by which time most of the Balkans was under Ottoman control. Ottoman expansion in Europe ended with their defeat in the Great Turkish War. In the Treaty of Karlowitz (1699), the Ottoman Empire lost most of its conquests in Central Europe. The Crimean Khanate was later annexed by Russia in 1783. Over the centuries, the Ottoman Empire gradually lost almost all of its European territories, until its collapse in 1922, when the former empire was transformed into the nation of Turkey.