The Barbary pirates operated out of the ports on the north African coast directly opposite Liguria, which although they were nominally part of the Ottoman Empire, were in reality military fiefdoms. The pirates sacked the towns all along the coast throughout the 16th-century, taking the locals as slaves to be sold on in the Middle East and Africa. One of the most notorious of these pirates was Turgut Reis (1485–1565), also known as Dragut. At home, as Pasha of Tripoli, he built one of the most impressive cities in north Africa, but he was less constructive abroad.
He was a sworn enemy of Genoa’s great admiral, Andrea Doria, and in 1540 captured several Genoese ships off the coast of Santa Margherita before he was in turn caught by Doria’s nephew and imprisoned in Genoa. The Genoese were, however, forced to release him when France allied with the Ottoman Empire. As a result, by 1545, he was back sacking the coast capturing Rapallo, Pegli and Levanto. The following year he took Laigueglia and Andora.
In 1547, he was appointed as the head of the Ottoman navy, but in 1549 he sailed towards Liguria again, this time with 21 galleys. He attacked Rapallo and in 1550 attacked Santa Margherita, after which Doria managed to trap Dragut in Djerba off the coast of Tunisia, although he managed to escape by dragging his fleet across the island. In 1551, he was back attacking Taggia. Doria set sail to do battle with 40 galleys in 1552 but was defeated by Dragut at the Battle of Ponza. Dragut himself was eventually killed during the siege of Malta in 1565 but pirate raids remained a danger along the coast into the 17th-century.