 In the same year, the king funneled water from the Guadalquivir from the castle to the inner city, spending a huge sum of money.He ordered the construction of the Alcazar, the Buhaira palace and the fortress of Alcalá de Guadaíra.He was defeated by Afonso I of Portugal at the Siege of Santarém (1184), in which he died.Ferdinand III of Castile, with the help of the fleet of Ramón de Bonifaz, broke the chains and with it the barrier of the bridge.