The decline of the Roman Empire, from the 5th century AD onward, and incursions by the Avars and Slavs at the end of the 6th century, prompted the Roman population to withdraw into easily defensible locations such as islands or peninsulas. This started local urbanisation and by the 7th century, under Byzantine rule, Piran had become heavily fortified. Despite the defences, the Franks conquered Istria in 788 and Slavs settled in the region. By 952, Piran had become a part of the Holy Roman Empire.