Original: It was built over the site of the former Visigothic cathedral, which under the Moors had been turned into a mosque.
Simplified: The mosque had been built where the former Visigothic cathedral had stood.