Between 639 and 640 AD. the Longobards of Arechi I of the Duchy of Benevento decided to wrest the city of Salerno from Byzantine rule without major bloodshed. In 646 Salerno became part of the Duchy of Benevento.
After the defeat of the Longobards in Pavia in 774 Arechi II decided to create a new fortified capital able to resist the advance of Charlemagne and promote good relations with Byzantium and Rome.
The city stood in an easily defensible place: the north was protected by the mountains and the castle that dominated the hill, while the plain of the Sele was a place to house the refugees who escaped the conquest of Lombardy Major.
In the spring of 787 Arechi II moved with his family and his court to Salerno, whose walls he had fortified. In April of the same year Arechi II received the Frankish ambassadors in the palace he had built and stipulated an honorable peace undertaking to pay a annual tribute of 7000 coins and offering the youngest son Grimoaldo hostage, together with twelve other Benevento nobles.
The refoundation of Salerno falls within those few cases of cities of little institutional importance which, during the Lombard age, became centers of civil or ecclesiastical territorial organization. The city continued to be a princely seat even after the death of Arechis II on 26 August 787, with his son Grimoaldo III until then held hostage in Aachen.