History of Portugal (1640–1777) put to the test in 1762 when Spain invaded aided by France, during the Seven Years' War. Britain invoked its alliance with Portugal and sent troops. Several months later, the conflict was settled with comparatively little fighting. In 1777, Spain and Portugal signed the Treaty of San Ildefonso, which mainly resolved a number of border disputes between their South American colonies. During the Age of Enlightenment, Portugal was considered one of Europe's unenlightened backwaters; it was a country of three million with 200,000 people in 538 monasteries in 1750. Melo seems to have been deeply embarrassed by Portugal's much lamented
Portugal I of Portugal signed with the king Fernando IV of Castile (which was represented, when being a minor, by his mother the queen Maria de Molina) the Treaty of Alcañices (1297), which stipulated that Portugal abolished agreed treaties against the kingdom of Castile for supporting the infant Juan de Castilla. This treaty established inter alia the border demarcation between the kingdom of Portugal and the kingdom of Leon, where the disputed town of Olivenza was included. The reigns of Dinis I (Denis I), Afonso IV (Alphons IV), and Pedro I (Peter I) for the most part saw peace with the