In one of these situations of conflict with the kingdom of Castile, Dinis I of Portugal signed with the king Fernando IV of Castile (who was represented, when 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 among other things the border demarcation between the kingdom of Portugal and the kingdom of Leon, where the disputed town of Olivenza was included.