The Byzantine cathedral of Hagia Sophia has been a source of wonder and fascination since its sixth-century construction. It was the premier monument of the Byzantine capital, Constantinople, and remains one of the most recognisable symbols of modern Istanbul. Often seen as encapsulating Byzantine history and culture, the building has been the subject of much scholarly interest since the Renaissance. However, while almost all previous archaeological work has focussed on the church itself, the surrounding complex of ecclesiastical buildings has been largely neglected. The research project presented here (co-directed by the authors) is the first to focus on the archaeology of the immediate environs of the church in order to understand the complex as a whole. Previously unrecorded material includes parts of the Patriarchal complex, from which the Orthodox Church was governed for almost a millennium, what may be the `Great Baptistery' north of the church, and what are perhaps the first fragments of the fourth-century phase of the cathedral yet identified. The discovery of an unrecognised porch, surviving to its full height within the standing building, changes the known plan of the famous sixth-century church. This new information provides fresh evidence about the appearance and function of the complex, illustrating its similarities to, and dissimilarities from, episcopal centres elsewhere in the Byzantine world. Combined with other archaeological sources, these discoveries enable us to place the sixth-century cathedral in its urban context and to reconsider what Hagia Sophia can tell us about the wider Byzantine world.