Sergius II was elected on January 25, 844, after the death of Gregory IV — though the popular Roman faction had elected a candidate named John, and the Roman aristocratic-clergy faction had to enthrone Sergius forcibly to prevent the popular candidate from prevailing. The contested election prompted Emperor Lothair I to send his son Louis II to Rome to enforce the Carolingian principle that no pope might be consecrated without imperial confirmation.
Sergius's pontificate is principally remembered for the catastrophic Saracen sack of Rome on August 23–26, 846 — when a Muslim fleet of approximately seventy-five ships sailed up the Tiber, sacked the extramural basilicas of St. Peter and St. Paul Outside the Walls, and looted the tombs of the apostles before being repulsed at the gates of the Aurelian walls.
The Saracen sack — the only successful foreign assault on the tombs of the apostles in the entire Christian history of Rome before the modern era — was the catastrophic event of the 9th-century Catholic Mediterranean crisis, prompting the construction of the Leonine Wall under Sergius's successor Pope Leo IV to enclose the Vatican.
Sergius II died on January 27, 847, leaving the defensive reconstruction of Rome to his successor Leo IV. The papal humiliation of the Saracen sack of the apostolic tombs would shape the Catholic understanding of Christian-Islamic confrontation for the next century.

