Complex sentence: The Almoravid dynasty lasted from 1040 to 1147, during which it ruled over what is now Southern Portugal.
Split into simpler sentences: The Almoravid dynasty lasted from 1040 to 1147. During some of that time it ruled over what is now Southern Portugal.