In the mid-16th century, the Ottoman empire expanded to encompass parts of the modern Sudan, Eritrea, and the Ethiopian borderlands, forming the Ottoman province of Habeş. The Ottomans also provided aid to their ally Ahmad Grañ in his jihad against Ethiopia and fought with the Funj sultanate of Sinnar for control of the Nile valley, where Ottoman territories briefly extended south as far as the Third Cataract. After 1579, Ottoman control was limited to the Red Sea coast, in particular the ports of Massawa and Suakin, which remained loosely under Ottoman rule until the 19th century, when they were transferred to Egypt, nominally an Ottoman vassal but effectively independent. Politically, Ottoman influence was felt much more broadly in northeast Africa in places as distant as Mogadishu, at least nominally recognized Ottoman suzerainty.