Byzantine emperor Justinian I rebuilt Singidunum from scratch in 535, restoring the fortress and city to its former military importance. Singidunum became an important border stronghold, however, Justinian rebuilt only the area within the former legion's camp. The city saw a brief peaceful period of about fifty years, but was then sacked with the arrival of the Avars in 584, though the Byzantines recaptured it in 596. The city remained under the constant attacks of the Avars and their allies at the time, Slavs. During Maurice's Balkan campaigns, Singidunum served as a base of operations, but it was lost again in the early half of the 7th century when the Avars sacked and burned Singidunum to the ground. The destruction of Singidunum and the collapse of the entire Limes Moesiae by the Avars occurred before 614 when Avars attacked the town of Niš, south of Singidunum. Around 630, the Slavs permanently settled in the area.