Henry II called Infante John to his court and gave him in marriage his illegitimate daughter Constance of Castile, in about 1378. When the Castilian army invaded Portugal, John joined its ranks and laid siege to Elvas, which held firm. Upon the death of Ferdinand I, John I of Castile had him arrested, considering him a threat as the most direct successor to the Portuguese throne. Meanwhile, his connections with Castile eventually cost him the throne, thanks to the argumentation of Master João das Regras at the Cortes of Coimbra in 1385. During the Battle of Aljubarrota he was already out of the country like his brother Denis, both of them having left Portugal for Castile, although during the 1383–85 crisis he was one of the claimants to the throne, along with Beatrice of Portugal (his half-niece), John, Master of Aviz (his half-brother) and Denís (his brother).