On 1 May 1865, Brazil, Uruguay, and Argentina signed the Treary of the Triple Alliance to defend themselves against aggression from Paraguay, which was ruled by Francisco López. López's troops were heading for the south of Brazil and the north of Uruguay after invading Brazilian territory through the Mato Grosso province and the north of Argentina. Many slaves had been incorporated into the Brazilian forces to face the increasingly serious situation. As a result of their solid performance during the conflict, the Armed Forces developed a strong sense against slavery. After five years of warfare (the largest in South American history), the Alliance led by Brazil defeated López. During this war, the Imperial Brazilian Army mobilized 200,000 men, divided into the following categories: 18,000 Army personnel who were in Uruguay in 1864; 2,047 in the province of Mato Grosso; 56,000 Fatherland Volunteers; 62,000 National Guardsmen; 11,900 freed slaves; and an additional 22,000 National Guardsmen who remained in Brazil to defend their homeland. In November 1889, after a long attrition with the monarchical regime deepened by the abolition of slavery, the army led a coup d'état that resulted in the end of the empire and the founding of a republic. The implementation of the first Brazilian military dictatorship (that ended in 1894), was followed by a severe economic crisis that deepened into an institutional one with Congress and the Navy, which degenerated into a civil war in the southern region. 20th century Between 1893 and 1927, during the First Brazilian Republic, the Army had to deal with various movements: some were derived from Navy and Army corps who were unsatisfied with the regime and demanded for democratic changes, while others had popular origins without conventional political intentions guided by messianic leaders, like in Canudos and the Contestado Wars. The Canudos War, which took place in the northeastern sertão and covered several cities and many sertanejos in Bahia led by Antônio Conselheiro, the Contestado War that developed by dispute of territories of currency of the states of Paraná and Santa Catarina, led by José Maria. These revolts were serious threats to the stability of the new republican regime and were related to the dissatisfaction of the population of the more distant northeastern sertão and regions of recent colonization like Paraná and western Santa Catarina with the Republic, since this population was predominantly Catholic and did not accept a Republic that appeared totally