On April 25, 799 the new Pope, Leo III, led the traditional procession from the Lateran to the Church of San Lorenzo in Lucina along the Via Flaminia (now Via del Corso). Two nobles (followers of his predecessor Hadrian) who disliked the weakness of the Pope with regards to Charlemagne, attacked the processional train and delivered a life threatening wound to the Pope. Leo fled to the King of the Franks, and in November 800 the King entered in Rome with a strong army and a number of French bishops. He declared a judicial trial to decide if Leo was to remain Pope, or if the conjurers' claims had reasons to be upheld. This trial, however, was only a part of a well thought out chain of events which ultimately surprised the world. The Pope, naturally was declared legitimate and the attempters subsequently exiled. On December 25, 800, Pope Leo III crowned Charlemagne Western Roman Emperor in St. Peter's Basilica.
This act forever severed the loyalty of Rome from its imperial progeny, Constantinople. It created instead a rival empire which, after a long series of conquests by Charlemagne, now encompassed most of the Christian Western territories.
Following the death of Charlemagne, the lack of a figure with equal prestige led the new institution into disagreement. At the same time the universal church of Rome had to face emergence of the lay interests of the City itself, spurred on by the conviction that the Roman people, though impoverished and abased, had again the right to elect the Western Emperor. The famous counterfeit document called the Donation of Constantine, prepared by the Papal notaries, guaranteed to the Pope a dominion stretching from Ravenna to Gaeta. This nominally included the suzerainty over Rome, but this was often highly disputed and as the centuries passed only the strongest Popes were to be able to assert it. The main element of weakness of the Papacy within the walls of the city was the continued necessity of the election of new popes, in which the emerging noble families soon managed to insert a leading role for themselves. The neighbouring powers, namely the Duchy of Spoleto and Toscana, and later the Emperors, learned how to take their own advantage of this internal weakness, playing the role of arbiters among the contestants.
Rome was indeed prey of anarchy in this age. The lowest point was touched in 897, when a raging crowd exhumed the corpse of a dead pope, Formosus, and put it on trial.
These crises were aggravated by the rise of another foreign power, the Arabs or, as the Middle Ages Italians called them, the Saracens: these newcomers, sailing from their bases in Northern Africa, had conquered Sicily and had began a steady penetration of Southern Italy. Infiltration of band of pirates brought terror in the territories around Rome. Under Pope Paschal I (817-824) all the spoils of the holy martyrs were transferred into the walls. But this move did not prevent a groups of Muslim to predate the St. Peter's Basilica itself, which was outside the ancient walls, sacking it in 846. In 852 Pope Leo IV commissioned therefore the construction of another wall around an area on the opposite side of the Tiber from the seven hills of Rome, which has since been called the Leonine City.