After the conquest of Toledo in 1085, Alfonso proclaimed himself (most victorious king of Toledo, and of Hispania and Galicia) This conquest, along with El Cid's taking of Valencia would greatly expand the territory and influence of the Leonese/Castilian realm, but also provoked an Almoravid invasion that Alfonso would spend the remainder of his reign resisting. The Leonese and Castilian armies suffered defeats in battles at Sagrajas (1086) and Uclés (1108), in the latter of which his only son and heir, Sancho Alfónsez, died, and Valencia was abandoned but Toledo remained part of an expanded realm that he passed to his daughter.