In 1521, the Portuguese allied with Hormuz and seized Bahrain from the Jabrid ruler Migrin ibn Zamil, who was killed during the takeover. Portuguese rule lasted for around 80 years, during which time they depended mainly on Sunni Persian governors. The Portuguese were expelled from the islands in 1602 by Abbas I of the Safavid dynasty of Iran, who declared Shia Islam the official religion of Bahrain. For the next two centuries, Iranian rulers retained control of the archipelago, interrupted by the 1717 and 1738 invasions of the Ibadhis of Oman. During most of this period, they resorted to governing Bahrain indirectly, either through the city of Bushehr or through immigrant Sunni Arab clans. The latter were tribes returning to the Arabian side of the Persian Gulf from Persian territories in the north who were known as Huwala (literally: those that have changed or moved). In 1753, the Huwala clan of Nasr Al-Madhkur invaded Bahrain on behalf of the Iranian Zand leader Karim Khan Zand and restored direct Iranian rule.
Rise of the Bani Utbah
In 1783, Nasr Al-Madhkur, ruler of Bahrain and Bushire, lost the islands of Bahrain following his defeat by the Bani Utbah tribe at the 1782 Battle of Zubarah. Bahrain was not new territory to the Bani Utbah; they had been a presence there since the 17th century. During that time, they started purchasing date palm gardens in Bahrain; a document shows that 81 years before arrival of the Al-Khalifa, one of the shaikhs of the Al Bin Ali tribe (an offshoot of the Bani Utbah) had bought a palm garden in Sitra island.
The Al Bin Ali were the dominant group controlling the town of Zubarah on the Qatar peninsula, originally the center of power of the Bani Utbah. After the Bani Utbah gained control of Bahrain, the Al Bin Ali had a practically independent status there as a self-governing tribe. They used a flag with four red and three white stripes, called the Al-Sulami flag in Bahrain, Qatar, Kuwait, and the