The Kilwa Sultanate was a Medieval sultanate, centered at Kilwa (an island off modern-day Tanzania), whose authority, at its height, stretched over the entire length of the Swahili Coast. It was founded in the 10th century by Ali ibn al-Hassan Shirazi, a Persian prince of Shiraz. His family ruled the Sultanate until the year 1277. It was replaced by the Arab family of Abu Moaheb until 1505, when it was overthrown by a Portuguese invasion. By 1513, the sultanate was already fragmented into smaller states, many of which became protectorates of the Sultanate of Oman.
The story of Kilwa begins around 960-1000 AD. According to legend, Ali ibn al-Hassan Shirazi was one of seven sons of a ruler of Shiraz, Persia, his mother an Abyssinian slave. Upon his father's death, Ali was driven out of his inheritance by his brothers. Setting sail out of Hormuz, Ali ibn al-Hassan, his household and a small group of followers first made their way to Mogadishu, the main commercial city of the East African coast. However, Ali failed to get along with the city's Somali elite and he was soon driven out of that city as well.
Steering down the African coast, Ali is said to have purchased the island of Kilwa from the local Bantu inhabitants. According to one chronicle (Strong, 1895), Kilwa was originally owned by a mainland Bantu king 'Almuli' and connected by a small land bridge to the mainland that appeared in low tide. The king agreed to sell it to Ali ibn al-Hassan for as much colored cloth as could cover the circumference of the island. But when the king later changed his mind, and tried to take it back, the Persians had dug up the land bridge, and Kilwa was now an island.