The background of the issue stretches mainly back to the Ottoman-Safavid era, prior to the establishment of an independent Iraq, which happened in the 20th century. In the early 16th century, the Iranian Safavids gained most of what is present-day Iraq, but lost it later by the Peace of Amasya (1555) to the expanding Ottomans. In the early 17th century, the Safavids under king ("shah") Abbas I (r. 1588–1629) regained it, only to lose it permanently (along, temporarily, with control over the waterway), to the Ottomans by the Treaty of Zuhab (1639). This treaty, which roughly re-established the common borders of the Ottoman and Safavid Empires the way they had been in 1555, never demarcated a precise and fixed boundary regarding the frontier in the south. Nader Shah (r. 1736–1747) restored Iranian control over the waterway, but the Treaty of Kerden (1746) restored the Zuhab boundaries, and ceded it back to the Turks. The First Treaty of Erzurum (1823) concluded between Ottoman Turkey and Qajar Iran, resulted in the same.