it was in the period of turmoil preceding the fall of the caliphates (in 1031) that sacavém was integrated into the kingdom of badajoz (except for a decade around 1020 when it was a part of al-ušbuna, under ʿabd al-ʿaziz ibn sabūr and ʿabd al-malik ibn sabūr (sons of sabūr al-saqlabi, a slavic serf who sparked a revolt in against caliph al-hakam ii). this would last until the aftasids conquered the region. in 1093, in a trade for aid against the almoravids (from the maghreb), the emir of badajoz ceded to the "imperator totius hispaniæ" alfonso vi of león and castile the castles of al-ušbuna and aš-šantaryin (santarém), along with the territory of sacavém. but the regions return to christianity lasted for a short time; in 1095, with the advance of the almoravid forces, led by yusuf ibn tashfin, count raymond of galicia was defeated in battle, resulting in the arab-christian frontier advancing from the tagus river to the mondego. by 1144, the al-garb led by ibn qasi revolted against the almoravids. although the almoravids were dominant in the first few years, they were in decline when afonso i of portugal definitively captured lisbon (al-ušbuna) in october 1147.