Religious Sanctuary
Religious sanctuary or right of asylum has been around in some shape or another for thousands of years. Around 600 AD king Æthelberht of Kent made the first laws regarding sanctuary. The person seeking asylum had to confess their crimes, surrender any weapons and be placed under the supervision of the head of the church or abbey. They were then given 40 days to make a choice: surrender to the authorities and stand trial; or confess there guilt and be exiled from the land. There were also two levels of sanctuary the lower level type, which all churches received, the individual was restricted to the confines of the church. And then the churches that got licensed by the king could offer much larger areas, in some cases up to 1 mile around the church. This boundary was set up with 4 markers, usually made of stone creating a square area around the church. Because the Hagia Sophia was commissioned by Justinian I as a place of worship for Christianity, it fell under these laws. I am unsure of what parts of the Hagia Sophia were considered “safe zones”, but if the whole building was one, then the criminal would have a lot of space to roam around. These laws are not in effect anymore. The churches still offer sanctuary but it carries no legal recourse and is only respected if the officers want to. In the modern age you hear very little of religious sanctuary anymore, but you do hear about political refugees. This term is just a new spin on an old tradition. Instead of churches, it is countries giving the sanctuary.
https://en.wikipedia.org/wiki/Right_of_asylum