Gubbio was a city of the ancient Umbri. Founded in the 3rd-century BC as Tota Ikuvina, it may have been their political and religious center. Gubbio assumed greater prominence in the 1st-century AD as the Roman town, Iguvium, and according to legend, was where Rome exported its lunatics.
Crazy or not, they enjoyed a period of peace and prosperity until the fall of the Roman Empire. In 552 Gubbio was attacked and destroyed by the Goths. Forty years later, the Goths lost the area to the Byzantines, and 200 years later (772), the Longobards took it from the Byzantines.
In the 1150s, twelve Umbrian cities under Frederick Barbarossa combined to attack it. The city was saved by its bishop, later Sant'Ubaldo, who persuaded the emperor to grant Gubbio its independence. As with other cities, there was continuous conflict between the comune and the ambitious nobles. One of them, Giovanni Gabrielli, became signore of the town in 1350, but four years later Cardinal Albornoz and his papal army captured it.
From 1387 to 1508, Gubbio was ruled from Urbino by the Dukes of Montefeltro. Gubbio remained part of the Duchy of Urbino until 1624, when it became part of the Papal states.