Shortly after the conquest of the region by the Arabs from the Byzantine Empire, Ceuta served as a staging ground in the Umayyad conquest of Hispania in 711, but it was destroyed in 740 and only rebuilt in the 9th century, passing to the Caliphate of Córdoba in the 10th century. In the subsequent centuries it remained under the rule of the Almoravids and Almohads as well as various Andalusian Taifas. Prior to its capture by the Portuguese, Ceuta had seen a period of political instability in previous decades, under competing interests from the Marinid Empire and the Kingdom of Granada. The attack on Ceuta also offered the younger nobility an opportunity to win wealth and glory. The chief promoter of the Ceuta expedition was João Afonso, royal overseer of finance. Ceuta's position opposite the straits of Gibraltar gave it control of one of the main outlets of the trans-African Sudanese gold trade; and it could enable Portugal to flank its most dangerous rival, Castile. The Portuguese fleet captained by King John I of Portugal held a Council of war, before carrying out the conquest of Ceuta, while anchored off Punta Carnero, Spain. On the morning of 21 August 1415, John I of Portugal led his sons and their assembled forces in a surprise assault on Ceuta, landing on Playa San Amaro. The battle itself was almost anti-climactic, because the 45,000 men who traveled on 200 Portuguese ships caught the defenders of Ceuta off guard. By nightfall the town was captured. On the morning of August 22, Ceuta was in Portuguese hands. Álvaro Vaz de Almada, 1st Count of Avranches was asked to hoist the flag of Ceuta, which is identical to the flag of Lisbon, but in which the coat of arms of the Kingdom of Portugal was added to the center, a symbol that still stands today. John's son Henry the Navigator distinguished himself in the battle, being wounded during the conquest. The looting of the city proved to be less profitable than expected for John I; he ultimately decided to keep the city, in order to pursue further enterprises in the area. Under King John's son, Duarte, the colony at Ceuta rapidly became a drain on the Portuguese treasury. Trans-Sahara caravans journeyed instead to Tangier. It was soon realised that without the city of Tangier, possession of Ceuta was worthless. In 1437, Duarte's brothers Henry and Ferdinand persuaded him to launch an attack on the Marinid sultanate. The resulting attack on Tangier, led by Henry, was a debacle. In the resulting treaty, Henry promised to deliver Ceuta back to the Marinids in return for allowing the Portuguese army to depart unmolested. Possession of Ceuta would indirectly lead to further Portuguese expansion. The main area of Portuguese expansion, at this time, was the coast of Morocco, where there was grain, cattle, sugar, and textiles, as well as fish, hides, wax, and honey. Ceuta had to endure alone for 43 years, until the position of the city was consolidated with the taking of Ksar es-Seghir, Arzila and Tangier. The city was recognized as a Portuguese possession by the Treaty of Alcáçovas and by the Treaty of Tordesilhas.