Ajuran-Portuguese war
The Ajuran-Portuguese wars were a series of armed military encounters between the Portuguese Empire and the Ajuran Sultanate, in the Indian Ocean and in East Africa. Background. In February 1507, an armada of 16 ships commanded by Tristão da Cunha and assisted by Afonso de Albuquerque docked at Malindi, en route to India via the island of Socotra. The King of Malindi had been a faithful vassal of the Portuguese since the maiden voyage of Vasco da Gama to India in 1497, and at that instance, the King requested assistance from the Portuguese against the hostile  cities of Oja, Lamu and Barawa. Oja was sacked and Lamu was subjugated without a fight. The Wars. Battle of Barawa. Upon reaching Barawa, the Portuguese first asked the city to submit without a fight, which was refused. The Portuguese made ready to assault the city, and reported that its defences included a wall and 4,000 men ready to fight. The European Age of discovery brought Europe's then superpower, the Portuguese empire, to the coast of East Africa, which at the time enjoyed a flourishing trade with foreign nations. The wealthy southeastern city-states of Kilwa, Mombasa, Malindi, Pate  and Lamu were all systematically sacked and plundered by the Portuguese. Tristão da Cunha then set his eyes on the Ajuran territory where the Battle of Barawa began where the Portuguese Empire decided to invade and capture the wealthy Somali harbour city. After a long period of engagement, the Portuguese soldiers burned the city and looted it. However, fierce resistance by the local population and soldiers resulted in the failure of the Portuguese to permanently occupy the city and eventually the Portuguese would be decisively defeated by the powerful Somalis from Ajuran Empire, and the inhabitants who had fled to  the interior would eventually return and rebuild the city. Tristão da Cunha was later severely wounded and sought refuge in Socotra islands after losing his men and ships. Aftermath of Barawa. After his loss in a battle with the Ajuran Empire, he decided to re-group his men in Socotra islands and set sail for Mogadishu. But word had spread of what had happened in Barawa, and a large troop mobilization had taken place. Many horsemen, soldiers and battleships in defense positions were now guarding the city. Nevertheless, Tristão still opted to storm and attempt to conquer the city, although  every officer and soldier in his army opposed this, fearing certain defeat if they were to engage their opponents in battle. After the attack, the city of Barawa was quickly rebuilt. Battle of Beandir. After the Portuguese lost a war against the Somalis of Ajuran Empire in the Battle of Barawa, the situation changed drastically in the Indian Ocean. The Somalis would use coastal guards to detect any threat of naval fleets that is trespassing the sea of Ajuran Empire and the coastal towers would use long-range handheld telescope easily spotting any ships miles away from their coast. The  word benadir means coast in Somali referring to the richness of southern Somali coast. Over the next several decades Somali-Portuguese tensions would remain high and the increased contact between Somali sailors and Ottoman corsairs worried the Portuguese who sent a punitive expedition against Mogadishu under João de Sepúlveda who was a powerful naval commander ordered by the Portuguese king to destroy Mogadishu, which was the richest city in Africa and one of the preeminent cities within the Indian Ocean. However, João de Sepúlveda and his 30 large naval fleets were detected by Ajuran coastal guards and were immediately reported  to the Ajuran naval commander called Ahmed Dheere and he sent large naval expedition against the Portuguese navy and managed to destroy all 24 naval fleets and simuteantly killing João de Sepúvelda in the battle. However, the 6 Portuguese fleets managed to slip through the battle and headed straight towards Mogadishu but luckily the 6 ships were detected by the Mogadishu towers guards and the Ajuran army with their purchase of advanced weapons like cannons managed to blow up all the six fleets into smithereens before they even had a chance to reach the Ajuran capital city leaving Mogadishu safe  and sound without a single harm being done to the metropolis city. Most of the Portuguese soldiers would be killed in the battle but the survivors were captured and enslaved in Somalia. Aftermath. Over the next several decades Somali-Portuguese tensions would remain high and the increased contact between Somali sailors and Ottoman corsairs worried the Portuguese who sent a punitive expedition against Mogadishu under João de Sepúlveda, which was unsuccessful. Ottoman-Somali cooperation against the Portuguese in the Indian Ocean reached a high point in the 1580s when Ajuran clients of the Somali coastal cities began to sympathize with  the Arabs and Swahilis under Portuguese rule and sent an envoy to the Turkish corsair Mir Ali Bey for a joint expedition against the Portuguese. He agreed and was joined by a Somali fleet, which began attacking Portuguese colonies in Southeast Africa. The Somali-Ottoman offensive managed to drive out the Portuguese from several important cities such as Pate, Mombasa and Kilwa. However, the Portuguese governor sent envoys to Portuguese India requesting a large Portuguese fleet. This request was answered and it reversed the previous offensive of the Muslims into one of defense. The Portuguese armada managed to re-take  most of the lost cities and began punishing their leaders, but they refrained from attacking Mogadishu, securing the city's autonomy in the Indian Ocean. The Ottoman Empire would remain an economic partner of the Somalis. Throughout the 16th and 17th centuries successive Somali Sultans defied the Portuguese economic monopoly in the Indian Ocean by employing a new coinage which followed the Ottoman pattern, thus proclaiming an attitude of economic independence in regard to the Portuguese.