Pope Alexander IV created the Treaty of Tordesillas to end the dispute between Portugal and Spain over land.
The land was split up between Portugal and Spain. The imaginary line of Demarcation was drawn north to sound from the Arctic pole to Antarctic pole. Three hundred and seventy leagues west of the Cape Verde Islands.
All land west of the demarcation line belonged to Spain, and all land east of the demarcation line belonged to Portugal.
If Spain were to discover land on Portugal's side of the demarcation line then the land would belong to Portugal. The same would go for Portugal if they discover land on Spain's side.
The Treaty of Zaragoza was then created as a revision of the Treaty of Tortillas to prevent any more conflict between Spain and Portugal. This treaty was created because some of Spain's land was on Portugal's side of the line.