Textual and material evidence suggests that early Byzantine architects, known as mechanikoi, were comprehensively educated in the mathematical sciences according to contemporary standards. This paper explores the significance of the astronomical and optical sciences for the working methods of the two mechanikoi of Hagia Sophia in Constantinople, Anthemios of Tralles and Isidoros of Miletus. It argues that one major concern in the sixth-century architectural design of the Great Church was the visual effect of its sacred interior, particularly the luminosity within. Anthemios and Isidoros seem to have been thoroughly conversant with the ancient corpus of astronomical and optical writings and, as will be shown, implemented their theoretical knowledge in the design of Hagia Sophia. Specifically, the paper demonstrates that the orientation of the building's longitudinal axis coincides with the sunrise on the winter solstice according to ancient computations, implying that the orientation was intentionally calculated in order to secure an advantageous natural illumination of the interior. Light and visual effects served to reinforce the symbolic significance of the sacred space that furthermore provides evidence for optical considerations with respect to late antique concepts of light and vision.