1349. His army was routed and he was killed in the Battle of Llucmajor on 25 October 1349. Imprisonment and marriage His father was killed at the Battle of Llucmajor in 1349 while attempting to recapture his kingdom, and James IV was taken prisoner by his uncle, Peter IV of Aragon. Now pretender to the Kingdom of Majorca and the Principality of Achaea, James was kept in an iron cage in Barcelona until 1362. He then contrived to escape and take refuge with Joanna I of Naples, who had aided his father's last attempt on Majorca. Joanna was then childless, and in need of an heir: she married James on September 26, 1363, at Castel Nuovo. Perhaps to avoid the civil strife of Joanna's first two marriages, James was carefully excluded from government of his wife's realm by the marriage contract. The marriage proved unsuccessful; however, in January 1365 Joanna was found to be pregnant with James IV's child, but unfortunately in June she had a miscarriage, as was noted in a letter of condolence sent to her by Pope Urban V dated 19 July 1365. They never conceived again. Struggle for Majorca James was determined to recapture his kingdom, and soon departed to make war on the Kingdom of Aragon. He was defeated and forced to flee to Bordeaux. There he gained the support of Edward the Black Prince, who he hoped would restore him to Majorca after restoring Peter the Cruel in Castile. He joined the invasion of Castile, taking part in the battle of Nájera (3 April 1367). He was stricken with a long and severe illness in Valladolid. Unable to ride, he could not leave the city and was captured by Henry II of Castile. Ransomed by Joanna, he returned to Naples only briefly before setting off again. Henry had launched a war against Peter IV of Aragon, and James hoped to take advantage of this to capture Roussillon and Cerdanya, the mainland portions of his father's realm. However, John of Gaunt procured a truce between Castile and Aragon, and the full weight of the Aragonese forces fell upon James. Defeated again, he fled into Castile, where he died of illness or poison at Soria on 20 January 1375, the 32nd anniversary of his wife's accession. His pretensions to Majorca passed to his sister Isabella, wife of John II of Montferrat. He willed his rights to