In 1514, Sultan Selim I (1512–1520) successfully expanded the empire's southern and eastern borders by defeating Shah Ismail I of the Safavid dynasty in the Battle of Chaldiran. In 1517, Selim I expanded Ottoman rule into Algeria and Egypt, and created a naval presence in the Red Sea. Subsequently, a contest started between the Ottoman and Portuguese empires to become the dominant sea power in the Indian Ocean, with a number of naval battles in the Red Sea, the Arabian Sea and the Persian Gulf. The Portuguese presence in the Indian Ocean was perceived as a threat to the Ottoman monopoly over the ancient trade routes between East Asia and Western Europe. Despite the increasingly prominent European presence, the Ottoman Empire's trade with the east continued to flourish until the second half of the 18th century.