Several political factions lobbied for possible husbands, which included English and French princes. Finally, the king settled for his wife's first choice, King John I of Castile. Ferdinand had waged three wars against Castile during his reign, and the marriage, celebrated in May 1383, was intended to put an end to hostilities by a union of the two crowns; however, this was not a widely accepted solution. This dynastic union meant that Portugal would lose independence to Castile; many nobles were fiercely opposed to this possibility, but they were not united under a common pretender to the crown. The two candidates, both illegitimate half-brothers of Ferdinand, were:

John, Great Master of Aviz, another natural son of Peter I, very popular among the Portuguese middle class and traditional aristocracy

On October 22, King Ferdinand died. According to the marriage contract, Dowager Queen Leonor assumed regency in the name of her daughter Beatrice and son-in-law, John I of Castile. Since diplomatic opposition was no longer possible, the party for independence took more drastic measures, starting the 1383–1385 crisis.

The regent's privy council made the error of excluding any representation of the merchants of Lisbon. The first move was taken by the faction of John (João) of Aviz in December 1383. João Fernandes Andeiro, Count of Ourém, called Conde Andeiro, the detested lover of the dowager queen, was murdered by a group of conspirators led by João of Aviz. Following this act, John, acclaimed "rector and defender of the realm" by the great Lisbon merchants,[2] was now the leader of the opposition to the pretensions of John I of Castile, who tried to be recognized as monarch iure uxoris, against the Treaty of Salvaterra.

The armed resistance met the Castilian army on April 6, 1384, in the Battle of Atoleiros. General Nuno Álvares Pereira won the battle for the Aviz party, but victory was not decisive. John I of Castile then retreated to Lisbon in May and besieged the capital, with an auxiliary fleet blocking the city's port in the river Tagus, in a severe drawback to the independence cause. Without the capital and its riches and commerce, little could be done to free the country from the Castilian king. On his side, John I of Castile needed Lisbon, not only for financial reasons, but also for political ones—neither he nor Beatrice had been crowned as monarchs of Portugal, and without a coronation in the capital he was only a designated king.

Meanwhile, John of Aviz had surrendered the military command of the resistance to Nuno Álvares Pereira. The general continued to attack cities loyal to the Castilians and to harass the invading army. John of Aviz was now focused on diplomatic offensives. International politics played an important role in deciding Portuguese affairs. In 1384, the Hundred Years' War was at its peak, with English and French forces in a struggle for the crown of France. The conflict spilled beyond the French borders, and influenced, for instance, the Western Schism in a papacy only recently moved to Avignon from Rome. Castile was a traditional ally of France, so, looking for assistance in England was the natural option for John of Aviz. In May, with Lisbon under siege, an embassy was sent to Richard II of England to make a case for Portuguese independence. In 1384, Richard was seventeen years old, but the power lay with his uncle John of Gaunt, 1st Duke of Lancaster, and regent of England. Despite initial reluctance to concede men, John of Gaunt finally agreed to levy troops to reinforce the Portuguese army.

Lisbon was struggling with famine and feared defeat by the Castilian siege. Blocked by land and by the river, the city had no hope of relief by the Aviz army, which was too small to risk an intervention and was occupied subduing other cities. An attempt was made by a Portuguese fleet to relieve the Castilian blockade. On July 18 a group of ships led by captain Rui Pereira managed to break the blockade and deliver precious supplies of food to Lisbon. The cost was high, since three of four boats were seized and Rui Pereira himself died in the naval combat. Despite this minor success, the siege held on; the city of Almada on the south bank of the Tagus surrendered to Castile. But the siege was hard not only on the inhabitants of Lisbon: the army of Castile was also dealing with a shortage of food supplies, due to the harassment of Nuno Álvares Pereira, and the bubonic plague. It was the outbreak of an epidemic in his ranks that forced John I of Castile to raise the siege on September 3 and retreat to Castile. Weeks later, the Castilian fleet also abandoned the Tagus, and Lisbon avoided conquest.

In late 1384 and the early months of 1385, Nuno Álvares Pereira and John of Aviz pursued the war, but they did not manage to subdue the majority of those Portuguese cities then in favour of the Castilian cause. Answering the call for help, English troops landed in Portugal on Easter Day. They were not a big contingent, around 600 men, but they were mainly veterans of the Hundred Years' War battles and thereby well schooled in successful English military tactics. Among them were a small number of longbowmen who had already demonstrated their value against cavalry charges, as at Crécy.

At the same time, John of Aviz organized a meeting in Coimbra of the Cortes, the assembly of the kingdom. There, on April 6, he was proclaimed the tenth king of Portugal, a clear act of defiance against the Castilian pretensions. John I of Portugal nominated Nuno Álvares Pereira Constable of Portugal and went to subdue the resistance still surviving in the north.

John I of Castile was not pleased. His first move was to send a punitive expedition, but the forces were heavily defeated in the Battle of Trancoso in May. From January, he began preparing his army to solve the problem definitively. The king himself led an enormous Castilian army that invaded Portugal in the second week of June through the central north, from Celorico da Beira to Coimbra and Leiria. An allied contingent of French heavy cavalry travelled with them. The power of numbers was on their side—about 32,000 men on the Castilian side versus 6,500 on the Portuguese. They immediately headed to the region of Lisbon and Santarém, the country's major cities.

Meanwhile, the armies of John I of Portugal and Nuno Álvares Pereira joined together in the city of Tomar. After some debate, a decision was made: the Castilians could not be allowed to besiege Lisbon once again, since the city would undoubtedly fall, so the Portuguese would intercept the enemy in the vicinity of Leiria, near the village of Aljubarrota. On August 14, the Castilian army, very slow due to its huge numbers, finally met the Portuguese and English troops. The ensuing fight, the Battle of Aljubarrota, was fought in the style of the Battles of Crécy and Poitiers. These tactics allowed a reduced infantry army to defeat cavalrymen with the use of longbowmen in the flanks and defensive structures (like caltrops) in the front. The Castilian army was not only defeated, but annihilated. Their losses were so great that John I of Castile was prevented from attempting another invasion in the following years.

With this victory, John I was recognized as the undisputed king of Portugal, putting an end to the interregnum and anarchy of the 1383–1385 crisis. Recognition from Castile would not arrive until 1411, after another Portuguese victory at the Battle of Valverde, with the signing of the Treaty of Ayllón. The English–Portuguese alliance would be renewed in 1386 with the Treaty of Windsor and the marriage of John I to Philippa of Lancaster, daughter of John of Gaunt. In 1387, taking advantage of the renewed alliance, John I, leading a Portuguese army of 9,000 men, reinforced by a 1,500-man English contingent that landed in Galicia, invaded Castile to sit John of Gaunt on the Castilian throne, which he claimed on his marriage to Infanta Constance of Castile. [3] The Castilian forces refused to offer battle, after two months no significant town was taken and the allies, struck by disease and lack of supplies, met with an overwhelming failure.[3]

^Robert Durand, in Encyclopedia of the Middle Ages (Routledge, 2000), s.v. "Portugal", p 1173; see also Armíndo de Sousa, "Portugal" in The New Cambridge Medieval History 2004, vol. II p. 629.

^"The urban masses, linked in a movement of social revolt not peculiar to Portugal alone, were skillfully manipulated by the burgesses, intellectual elite and discontented nobility in support of what amounted to a palace revolution to regain lost honour and avenge insult... The coup, masterminded by the nobility, was soon transformed into a popular and nationwide revolution," observes Armíndo de Sousa (2004:629).

^ abGoodman, Anthony: John of Gaunt: The Exercise of Princely Power in Fourteenth-Century Europe. New York: St. Martin's Press, 1992. ISBN 9780312083588, p. 123.