The second wall system was realized in the Middle Ages (12th century), after the destruction of the city by Frederick I Barbarossa.
In the Imperial era, while Mediolanum was capital of the Western Roman Empire, Emperor Maximian enlarged the city walls; to the east, this was intended to include the Hercules' thermae (located in the surroundings of what are now Piazza San Babila, Corso Europa and Piazza Fontana); to the west, the new walls enclosed the arena.
In the beginning, a deep moat was realized, filled up with water drawn from the Seveso and Nirone [it] rivers.
The perimeter of the Spanish walls essentially corresponds to what is now known as the "Cerchia dei Bastioni" ("Bastion Ring").
Stendhal has described this promenade in his diary Rome, Naples et Florence; at the time, a passer-by would be able to see the Duomo from anywhere on the walls.
When Milan was annexed to the Napoleonic Empire, governor Francesco Melzi d'Eril ordered the demolition of the Spanish walls and the replacement of the original gates.
At the time, the gates were to serve as customs duty stations, and their architecture was supposed to reflect the grandeur of the Napoleonic Empire as well as the role of Milan as the capital of the Kingdom of Italy.