While studying law at the University of Coimbra, Alegre was noticed for his opposition to António de Oliveira Salazar's dictatorial government - the Estado Novo regime. He was conscripted, and sent to the Azores and later to Portuguese Angola, where his involvement in an attempt to military rebellion led to his imprisonment. After serving his prison term in Luanda, he returned to Coimbra, before going into exile in 1964. As a student at the University of Coimbra he was a very active figure of the Associação Académica de Coimbra, the university's student's union, while member of the governing body, athlete and cultural agent (poetry and theatre). He would never graduate in law.