His rivalry with Gerardo Barrios, President of El Salvador, resulted in open war in 1863. At Coatepeque the Guatemalans suffered a severe defeat, which was followed by a truce. Honduras joined with El Salvador, and Nicaragua and Costa Rica with Guatemala. The contest was finally settled in favor of Carrera, who besieged and occupied San Salvador, and dominated Honduras and Nicaragua. He continued to act in concert with the Clerical Party, and tried to maintain friendly relations with European governments. Before he died, Carrera nominated his friend and loyal soldier, Army Marshall Vicente Cerna y Cerna, as his successor.