Lagos's interest in politics began while he was a university student. At 18, he was elected president of a student group. In 1961, he left the Radical Party after it backed the conservative Jorge Alessandri for president, and he moved ideologically closer to the Socialist Party (PS). During the Allende administration, he was named secretary-general of the University of Chile and was the president's choice to be ambassador to Moscow. But he was never to take that post. The military coup on 11 September 1973 and the repression that followed forced Lagos to leave for Argentina, and later the United States, where he taught at the University of North Carolina until 1975. From 1976 to 1984, Lagos worked as an economist for United Nations (UN) agencies. He began to take a more active role in the opposition to Pinochet when he returned to Chile in 1978. In the early 1980s, Lagos and many other Chileans founded the Alianza Democratica (Alliance for Democracy) to oppose military rule. He was president of the Alliance in 1983–84, becoming a prominent voice for the left. In 1986, leftist rebels attempted to assassinate Pinochet. In the crackdown that followed, Lagos and many other opposition leaders who were not involved in the plot against the dictator were detained, and Lagos spent 20 days in prison. In 1987, Lagos founded the Party for Democracy (PPD), which pressed for an end to the dictatorship.
During the yes/no plebiscite campaign for continued Pinochet rule, Lagos traveled throughout the country encouraging Chileans to let go of their fears and register to vote. In a now-famous televised political roundtable, Lagos pointed a finger to the camera and said "you, Mr. Pinochet are responsible" for violations against human rights. Lagos's defiance boosted his political career, and his direct attack on Pinochet was credited for loosening the fear that gripped Chileans. He played a pivotal role during the plebiscite, but it was not enough to bring him to office. His ties to the left hurt him during the 1989 campaign for a Senate seat, when he garnered only 30% of the vote. But President Patricio Aylwin named him minister of education. In one of his most notable actions, he prohibited schools from preventing pregnant girls from attending classes.
In 1993, with the backing of the PPD, Lagos sought to become the Concertación's second presidential candidate, but he was defeated in the primaries by Eduardo Frei Ruiz-Tagle, who went on to become president. Frei named Lagos minister of works. Lagos used the post to build a solid reputation as a capable technocrat. By 1996 and 1997, polls consistently named Lagos as one of the most important political figures in Chile and the most likely person to become Chile's third freely elected president since Pinochet. At least within the Concertación, no one measured up to Lagos's stature. During a primary to decide the Concertación's presidential candidate in May 1999, Lagos received 71.34% of the vote to defeat Andrés Zaldivár, a Christian Democrat and Senate president, who received 28.7% of the vote. At first, Lagos was an overwhelming favorite to win the presidency over the conservative candidate Joaquín Lavín, a former member of the Pinochet government. But Lavín's appeal to working classes, growing dissatisfaction with the Concertación, and a troubled economy after many years of growth hurt Lagos. In the December 1999 election, Lagos and Lavín, who distanced himself from Pinochet after his arrest, finished in a virtual tie, with a little more than 49% for each candidate. While Lagos finished slightly ahead of Lavín, he did not gain the necessary 51% of the vote to avoid a runoff election. With the key backing of influential politician Soledad Alvear, and votes from Communist Party members, Lagos narrowly defeated Lavín, 51.3% to 48.7%, in the January 2000 run-off for the presidency. On 11 March, Lagos was inaugurated president.