From 1903 until 1968, Panama was a republic dominated by a commercially-oriented oligarchy. During the 1950s, the Panamanian military began to challenge the oligarchy's political hegemony. The January 9, 1964 Martyrs' Day riots escalated tensions between the country and the U.S. government over its long-term occupation of the Canal Zone. Twenty rioters were killed, and 500 other Panamanians were wounded.
In October 1968, Dr. Arnulfo Arias Madrid, elected president for the third time and twice ousted by the Panamanian military, was again ousted (for the third time) as president by the National Guard after only 10 days in office. A military junta government was established, and the commander of the National Guard, Brig. Gen. Omar Torrijos, emerged as the principal power in Panamanian political life. Torrijos' regime was harsh and corrupt, and had to confront the mistrust of the people and guerrillas backing the populist Arnulfo Arias. However, he was a charismatic leader whose Socialist domestic programs and nationalist foreign policy appealed to the rural and urban constituencies largely ignored by the oligarchy.
On September 7, 1977, the Torrijos-Carter Treaties were signed by the Panamanian head of state as well as U.S. President Jimmy Carter, for the complete transfer of the Canal and the fourteen US army bases from the US to Panama by 1999 apart from granting the U.S. a perpetual right of military intervention. Certain portions of the Zone and increasing responsibility over the Canal were turned over in the intervening years.