In 1859, Peru had a confrontation with neighboring Ecuador over disputed territory bordering the Amazon. Though Peru was considered successful, Castilla failed to secure a definitive agreement with Ecuador and the issue would haunt both countries until the end of the 20th century when the 1997 Peace and Border Treaty of Itamaraty was signed by Peru and Ecuador in Brazil. In December 1860 a new constitution was enacted during Castilla's presidency and became Peru's supreme law until 1920. Castilla's second presidency, therefore, was marked by the liberation of slaves and indigenous Peruvians, as well as a new postal system and a new constitution.