Accession and rebellion
After the death of Leo VIII, the Roman nobility asked the Holy Roman emperor, Otto I, for the reinstatement of Pope Benedict V. When this was not possible, Bishop John was suggested as a compromise candidate by Otto's envoys, the bishops Otger of Spiers and Liutprand of Cremona. Elected unanimously, John was consecrated on Sunday, 1 October 965, five months after the death of Leo VIII.
John immediately took on the task of curbing the power of the Roman nobility. He gave members of the Crescentii family important positions to shore up his support, while he also sought closer ties with the emperor. However, with the emperor back in Germany, various local powers decided to take advantage of his absence to intrigue against John XIII. The former king Adalbert of Italy had appeared in front of an army in Lombardy, whilst the Roman nobility, disliking John's behaviour, and resenting his imposition by a foreign power, staged a revolt. Under the leadership of Peter, the Prefect of the city, together with Rofred, the Count of Roman Campagna and the Vestararius Stephen, they roused the Roman nobility by declaring that
”The Saxon kings were going to destroy their power and influence, and were going to lead their children into captivity.”
The leaders of the Roman militia captured the pope on 16 December 965, and imprisoned him in Castel Sant'Angelo. However, fearing John's presence there would inspire resistance from his followers, the pope was moved to one of Rofred's castles in the Campagna. Word eventually reached Otto of all these disturbances, and he entered Italy in late summer of 966 at the head of an enormous army. In the meantime, John had managed to escape from Campagna, and made his way to Capua, placing himself under the protection of Pandulf Ironhead. In thanks for Pandulf's aid, John converted Capua into a Metropolitan see, and consecrated as its first archbishop Pandulf's brother John, on 14 August 966. In Rome, the pope's supporters rose up, and Rofred and Stephen were killed by John Crescentius, son of Crescentius "of the Marble Horse". Pope John left Capua, and crossed into Sabina, where he was met by his brother-in-law, Benedict, who also offered John his support. With Rome effectively back in his hands, John returned and was welcomed back into the city on 14 November 966. Although he was initially lenient towards the rebels, the arrival of Otto saw a change in approach. The emperor banished to Germany the two men appointed consul; the twelve principal militia leaders (the Decarcones, one appointed to each of the city's twelve regions) were hanged. Other plotters were either executed or blinded. The Prefect of the city, Peter, was handed over to John, who ordered him to be hung by his hair from the Equestrian Statue of Marcus Aurelius, after which he was taken down, placed naked and backwards on an ass. A bag of feathers was placed upon his head and two more at his thighs. With a bell fastened round its neck, Peter was driven through the city, and after being thus exposed to the ridicule of the people, Peter was cast into a dungeon before finally being sent by the emperor into Germany. In gratitude for the emperor's intervention, John lauded him by declaring him to be the liberator and restorer of the Church, the illustrious guest, and three times blessed emperor.
In 969, he met Gerbert d'Aurillac, the future Pope Sylvester II, and was so impressed by his scholarly brilliance that he kept him on in Rome in order to learn from him.