Damascus Syria was the capital of the Umayyad Caliphate. After they were overthrown by the Abbasid Caliphate they fled to Spain where they established a new Caliphate called the Caliphate of Cordoba.
The Abbassids built Baghdad, in modern-day Iraq, as their capital. It remained their capital until Hulegu Khan sacked it and destroyed the Abbassid Caliphate.