This led to a rebellion by the Roman citizens, headed by Gregory, Count of Tusculum (Frascati); Otto was besieged in his palace and then driven from the city. He withdrew to Ravenna to do penance in the monastery of Sant'Apollinare in Classe. After having summoned his army, Otto headed southwards to reconquer Rome, but died in the castle of Paterno, near Civita Castellana, on 24 January 1002.
On 15 June 1155 Frederick Barbarossa was crowned emperor by Pope Adrian IV but the Roman people rose up against Frederick Barbarossa and the Pope convinced him to abandon Rome not too much sure. Frederick Barbarossa encamped at Ponte Lucano, near Tivoli. On 28 June 1155 the tiburtine people gave the key of the town to the emperor.
Afterwards Barbarossa gave back the town to Pope, who asserted that " ab antiquo" the Church had the jurisdiction on Tivoli. Anyway Barbarossa wanted that Tivoli was fortified for strategic reasons against Rome. The town regained its former splendour: new city walls were put up and the urban area was remarkably enlarged (later the town was divided into 4 districts: Castrovetere, St.Paul, St.Croce and Trevio).
Tivoli became for some time the stronghold of the Ghibeline party.
Between the XI and the XII century many turret-houses were built inside the urban area. These very high, quadrangular constructions, were used both as dwellings and as defence. They were placed in the strategic points of the town. Some beautiful examples can still be admired today in Vicolo dei Ferri, Via del Tempio d'Ercole, Via della Sibilla, Via del Seminario, Via del Seminario, Piazza Rivarola and Piazza Palatina. This place, togheter with Piazza delle Erbe, was the centre of civil, municipal and religious life: there were, and can still be admired today, the Arengo Palace (municipal palace), the Tower House and the Church of St. Michael date back approximately from the same period.
On 22 November 1220 Frederick II (grandson of Barbarossa) was crowned Holy Roman emperor by Pope Honorius III but in 1227 he was excommunicated by Pope Gregory IX for failing to honor his crusading pledge. Relationship between Papacy and Empire made worse. Tivoli supported the Emperor in his fight against the Pope. Roman troops assaulted the Imperial garrison in Tivoli in 1241 and the Emperor soon reached Rome. This back-and-forth situation was repeated again in 1242 and 1243.
In 1259 Tivoli lost its independence because of the death of Emperor Frederic II in 1250 and the consequent weakness of the imperial party. The Senate of Rome succeeded (under Pope Innocent IV) in imposing a tribute on the city, and arrogated to itself the right of appointing a count to govern it in conjunction with the local consuls.
To control the people and reduce them to obedience, in 1461 Pope Pius II erected the present castle ((Rocca Pia), a quadrilateral fortress composed of four round corner-towers.