It was built in the fifteenth century by Francesco Sforza, who recently became Duke of Milan, on the remains of a previous fortification dating back to the fourteenth century known as Castrum Porte Jovis (Castle of Porta Giovia or Zobia). Over the centuries it has undergone significant transformations. Between the sixteenth and seventeenth centuries it was one of the main military citadels in Europe. Restored in historicist style by Luca Beltrami between 1890 and 1905. Now it is home to important cultural institutions and a tourist destination. It is one of the largest castles in Europe.
The construction of a fortification with defensive functions was started in the second half of the fourteenth century by the Visconti dynasty. In 1354 Archbishop Giovanni Visconti, dying, bequeathed the duchy to his three nephews Matthew II, Galeazzo II and Bernabò. Between 1360 and 1370 Galeazzo Visconti had a fortification called Castello di Porta Giovia built, named after the ancient entrance to the Roman walls dedicated to Jupiter. The building was enlarged by his successors. Gian Galeazzo Visconti, who became the first Duke of Milan in 1395. Giovanni Maria and Filippo Maria. The result is a square-plan castle, with sides 200 meters long. Four corner towers, two of which face the city with perimeter walls 7 meters thick.
The building thus became the permanent home of the Visconti dynasty which was then destroyed in 1447. It was the captain of fortune Francesco I Sforza who started the reconstruction in 1450 to make it his residence. Not being of noble origins, and not having his own coat of arms, he kept the Visconti viper as the coat of arms of his family. In 1452 Filarete was hired for the construction and decoration of the median tower. On the death of Francesco, his son Galeazzo Maria had the work continued by the architect Benedetto Ferrini.
In these years a great campaign of frescoes in the halls of the ducal court was launched. In 1476, under the regency of Bona di Savoia, the tower of the same name was built. In 1494 Ludovico il Moro came to power and the castle became the seat of one of the richest and most sumptuous courts in Europe. Artists such as Leonardo da Vinci (who frescoed several rooms of the ducal apartment) and Bramante were called to work. In particular, Leonardo's painting of Vegetable intertwining with fruits and monochromes of roots and rocks in the Sala delle Asse, dated 1498.
In the following years the castle was damaged by the constant attacks that French, Milanese and Germanic troops exchanged. An elongated bulwark called "pincers" was added, which gives its name to the nearby gate and perhaps designed by Cesare Cesariano, but in 1521 the Torre del Filarete exploded, because a French soldier accidentally detonated a bomb after the tower was used as an armory.
Returning to power and to the castle, Francesco II Sforza renovated and enlarged the fortress, using a part of it as a sumptuous home for his wife Christina of Denmark. During the twentieth century the castle was damaged and renovated after the Second World War; in the nineties a large fountain was built in piazza castello inspired by one previously installed on site which was dismantled in the sixties during the works for the construction of the first subway line and no longer remodeled after the completion of the works. The last restoration of courtyards and halls.