In the year 626, the Byzantine Empire was experiencing political turmoil. The emperor Phocas had recently been overthrown by a young general, Heraclius, and the empire had been invaded by both the Persians to the East and the Avars to the West.
Wars with the Persians in the East had been ongoing since the time of Justinian in the early 500s, with the Persian Emperor Khosroes not allowing Byzantine trade through the Persian Empire and threatening to invade. The Avars, a people of Tartar origin, were also being paid off since the time of Justinian to protect the borders of Byzantium. When the payments stopped during the reign of the Emperor Justin they turned against Byzantium.
And so in 626 the Persian and Avar leaders coordinated to draw Heraclius and the army away from Constantinople and then send their remaining forces to lay siege to the city. And so Constantinople found itself under siege with the majority of its army away fighting the Persians.
The Byzantine defenders had roughly 10,000 men to defend the city walls (mostly dismounted cavalry troops) against a force of over 50,000 Avars and Persians. The Avars had moored their fleet just outside the city and had moved up siege towers to the Theodosian walls
The defence of the city thus fell to Patriarch Sergius and the magistrate Bonus. Although an inexperienced military leader, the Patriarch was nonetheless a man of immense faith and courage. Every day he would parade the icon of the Virgin Mary around the walls of the city and proclaim that God was on the side of the defenders
Throughout July and into August, the besiegers continually assaulted the walls of the city. Every successive wave was beaten back by the defenders and the Avars suffered such heavy losses that they were not even able to collect their dead and wounded. On August 4 they launched a massive assault and managed to occupy the outer suburbs of the city, burning down many houses and the church of Theotokos of Blachernae.
On August 7, they launched one final land and sea assault. The Byzantine navy sallied forth and destroyed their entire fleet. Patriarch Nikephoros. Writing on the siege at a later date, mentions that the sea became red from the blood. Theodore Syncellos writes that the sea near Blachernae was covered with dead bodies and empty boats floating aimlessly.
The sources tell us that the King of the Avars looked up at the walls of the city while his fleet was being destroyed and saw a woman in shining garments with a face full of light – this was undoubtedly the Theotokos. The Avars and Persians were forced to retreat and their land forces were defeated in battle by Emperor Heraclius shortly afterwards.
In celebration, the Patriarch ordered that an all-night vigil be held to give thanks to the Panagia where the city chanted the Akathist Hymn – 24 verses long starting with the letters of the Greek alphabet.
The Akathist Hymn was penned around this time by an unknown writer – either the Patriarch himself or another priest of the city.
The words of the hymn are as follows: O Champion General, we your City inscribe to you the prize of victory as gratitude for being rescued from calamity, O Theotokos. But since you have invincible power, free us from all kinds of perils so that we may cry out to you: Rejoice, O Bride unwedded.