On 9th April 491 the Emperor Zeno died in Constantinople, having final freed the Eastern Empire from the Goths. He had no heir and his brother Longinus was passed over as successor in favour of Flavius Anastasius. Anastasius had a reputation for uprightness and integrity, but was also puritanical and parsimonious. He banned contests with wild beasts and outlawed nocturnal feasts.
Anastasius was genuinely pious, but his move towards monophysitism gave rise to unrest, fomented by Longinus. In 492 Longinus was arrested and exiled, but the situation soon escalated into civil war. Only with great difficulty was order restored, after which all Isaurians were banned from the capital although the war continued for three more years in Anatolia.
Another cause of unrest was the rivalry between the Blues and the Greens. The names originally referred to the colours worn by two teams of charioteers, but their leaders were appointed by the government, who used the two factions on guard duties around the city walls. This led to a polarisation, with the Blues representing the big landowners, aristocracy and religious orthodoxy, and the Greens, traders, civil service and monophysitism. Disturbances increased and in 511 the Patriarch Euphemius, was accused of supporting the Isaurians, and was banished. His successor, Macedonius, was accused of starting a riot, and at that point an angry crowd marched on the palace. Macedonius rushed to the Emperor's side and the crowd dispersed. Macedonius was exiled all the same and in November 512, three days of rioting broke out. The day was saved when the Emperor appeared in the Circus before 20,000 of his subjects. He removed his crown and offered to abdicate if the crowd would name his successor. They couldn't.
So legend goes, Anastasius was curious to know which of his three nephews would be his successor. He invited them to dinner and arranged for there to be three couches, with a note saying "REGNUM" under a pillow of one of them. Two of the nephews decided to occupy one couch and the one with the note remained unoccupied. After much praying, it was revealed that his successor would be the man who first entered his bedchamber the next day. That man turned out to be Justin, Commander of the Excubitors.
Anastasius finally died 1st July 518 without naming a successor.