An unwise foreign policy simultaneously injured the royal prestige, for Afonso married his own niece, Joanna, daughter of Henry IV of Castile, and claimed the kingdom of Castile in her name. At the Battle of Toro, in 1476, he fought an indecisive battle that made him realize that his claims to the Castilian throne were not achievable. However, Portugal defeated Castile in the naval war (1475–79) of the same conflict (War of the Castilian Succession), capturing a large Castilian fleet -full of gold- in the Battle of Guinea (1478).