The area was inhabited still before Roman times, as can be derived from archaeological findings of the 6th century BC with small hamlets as Ozzero founded by the Celtic populations of Lombardy. The Roman occupation that lasted from the 1st century BC to the 5th century AD left a great number of traces along the Via Mercatorum that connected the villages east of the Ticino. These settlements were called cascinae, and numerous findings show that the local economy was very lively, mostly based on the production of cereals, wine and oil. After the fall of the Roman Empire the area came under the Lombards, who established their center around the church of San Pietro; later on the town was under the rule of the Archbishop of Milan, who ordered a castle to be built near Santa Maria Vecchia. This early castle was destroyed by Frederick Barbarossa in 1162.
The early borough was surrounded by walls with 4 gates - San Pietro to the north, Milano to the East, San Martino to the south and the Porta Nuova to the west. In 1176 the canal called Navigium (present-day Naviglio Grande) was begun, and when finished this masterly engineering project connected Milan, the Ticino and Lake Maggiore.
In the following century the town was under the Visconti (1277-1450), then the Sforza (1450-1535), the Spaniards (1535-1707) - a period well described in Manzoni's "The Betrothed" and finally the Austrians (1707-1859). In the later 19th century the Industrial revolution started to change this part of Italy, and soon the population grew and new districts were built outside the medieval walls.