By the mid-17th century the Ottoman Empire had reached its greatest extent , stretching from Batumi at the eastern end of the Black Sea to Algeria , taking in Mesopotamia , Palestine , the shores of the Red Sea ( including Mecca and Medina ) , Egypt , Anatolia , Greece , the Balkans , Hungary , Moldavia , the North African coast , the Crimea , and southern Ukraine .
Ottoman rule was welcomed in all of its territories through the 17th century .