In January 532 a riot that began in the hippodrome over the treatment of two condemned partisans turned into an insurrection that burned the centre of Constantinople and came close to putting another man on the throne. When it was over the cathedral was ash, and Justinian rebuilt it on a plan nothing in the Roman world had prepared anyone for.
The design was given to two men described as mechanikoi rather than as ordinary builders: Anthemius of Tralles, a mathematician who wrote on conic sections, and Isidore of Miletus, who taught geometry. Their solution set a shallow dome over a square by carrying it on four pendentives, curved triangles of masonry filling the corners, and then buttressed the whole thing east and west with half domes so that the interior reads as a single continuous space rather than a series of rooms. A ring of forty windows at the base of the dome makes the masonry above appear to float, an effect contemporaries wrote about at length. The church was dedicated in 537, less than six years after the fire.
It was not a solved problem. The first dome was too shallow, and it came down in 558 after earthquakes; the replacement was raised higher and has largely survived. The remark Justinian is supposed to have made at the dedication, that he had outdone Solomon, does not appear in the contemporary account by Procopius and is first found in a much later legendary narrative about the building, which is a useful reminder of how quickly a monument acquires the words it ought to have had.