At the beginning of 1548 Cosimo I de' Medici was asked by Carlo V to defend Elba (and therefore also the commercial traffic in the Tirreno Sea), and to fortify the town of Ferraja. That same year, in May, the architect Balducci, with the help of Camerini, started fortifying Cosimo's town, which he called "Cosmopoli". Thanks to its natural shape, with a steep cliff jutting out on either side and a long, narrow strip of land that almost closed the port in, it was perfect for defence, and was easily turned into an impregnable fortress: Forte Stella and Forte Falcone were built on the highest parts of the promontory in Portoferraio, and Forte della Linguella was built on the strip of land that closed the port in.
After this, the whole town of Cosmopoli was surrounded by walls and ramparts, skillfully designed by the architect Bernardo Buontalenti. In 1600, according to Admiral Nelson, the moat that separated Portoferraio from the rest of the Island made this fortified town a "completely impregnable island".
Both Cosmopoli and the way it had been fortified were put to the test immediately in 1555, when Dragut the pirate, after having conquered Capoliveri, Rio, San Piero, Sant'Ilario and Pomonte, had no choice but to leave the Island without having been able to conquer Portoferraio, and head for Corsica.
In defence of the Mediterranean, and in an attempt to keep the Turkish pirates away, Cosimo I established the Order of the Santo Stefano Knights based on the Order of the Knights of Malta; with their help he had the San Salvatore Convent built - (today the De Laugier Barracks) - which became their headquarters and the arsenal of the Galezze for their ship maintenance.
With the downfall of the Medici dominion, Cosmopoli, as did all the Granducato, passed into the hands of the Lorena family, then fell under the French, then, more than two hundred years later, Portoferraio became part of the projects of one of history's best strategists: Napoleon Bonaparte.