It was founded by Cosimo I de' Medici, Grand Duke of Tuscany, in 1548, with the name of Cosmopoli ("Cosimo's City"), to balance the presence of the Spanish citadel in Porto Azzurro. It had three forts (Forte Stella, Forte Falcone and Forte Inglese) and a massive line of walls, all still visible today.
The city remained to the Grand Duchy of Tuscany until the 18th century, when, due to its strategic position, it was contended by France, England and Austria. In 1814 it was handed over to Napoleon Bonaparte, as the seat of his first exile.
In the 19th century, the city grew quickly, due to the construction of infrastructures and the exploitation of new iron mills in Rio Marina. Portoferraio became then main shipping port of the ore towards the mainland, whence the current name, meaning "Iron Port" in Italian.
After the end of the Napoleonic Era, Portoferraio returned to Tuscany, and became part of the Kingdom of Italy in 1860.