Its founding  goes back to 1551, when Carlos I, King of Spain (Charles V, Emperor of the Holy  Roman Empire) decreed the foundation of the University of Mexico.
The university was renamed on 22 September 1910 by Justo Sierra, then Minister of Education in the Porfirio Díaz regime, who sought to create a very different institution from its 19th-century precursor, the Royal and Pontifical University of Mexico, which had been founded on 21 September 1551 by a royal decree signed by Crown Prince Phillip on behalf of Charles I of Spain and brought to a definitive closure in 1865 by Maximilian I of Mexico.
Instead of reviving what he saw as an anachronistic institution with strong ties to the Roman Catholic Church, he aimed to merge and expand Mexico City's decentralized colleges of higher education (including former faculties of the old university) and create a new university, secular in nature and national in scope, that could reorganize higher education within the country, serve as a model of positivism and encompass the ideas of the dominant Mexican liberalism.

The project initially unified the Fine Arts, Business, Political Science, Jurisprudence, Engineering, Medicine, Normal, and the National Preparatory schools; its first rector was Joaquin Eguía y Lis.

The new university's challenges were mostly political, due to the ongoing Mexican Revolution and the fact that the federal government had direct control over the university's policies and curriculum; some resisted its establishment on philosophical grounds.
This opposition led to disruptions in the function of the university when political instability forced resignations in the government, including that of President Díaz.
Internally, the first student strike occurred in 1912 to protest examination methods introduced by the director of the School of Jurisprudence, Luis Cabrera.
By July of that year, a majority of the law students decided to abandon the university and join the newly created Free School of Law.

In 1914 initial efforts to gain autonomy for the university failed.
In 1920, José Vasconcelos became rector.
In 1921, he created the school's coat-of-arms: the image of an eagle and a condor surrounding a map of Latin America, from Mexico's northern border to Tierra del Fuego, and the motto, "The Spirit shall speak for my race".
Efforts to gain autonomy for the university continued in the early 1920s.
In the mid-1920s, the second wave of student strikes opposed a new grading system.
The strikes included major classroom walkouts in the law school and confrontation with police at the medical school.
The striking students were supported by many professors and subsequent negotiations eventually led to autonomy for the university.
The institution was no longer a dependency of the Secretariat of Public Education; the university rector became the final authority, eliminating much of the confusing overlap in authority.

During the early 1930s, the rector of UNAM was Manuel Gómez Morín.
The government attempted to implement socialist education at Mexican universities, which Gómez Morín, many professors, and Catholics opposed as an infringement on academic freedom.
 Gómez Morín with the support of the Jesuit-founded student group, the Unión Nacional de Estudiantes Católicos, successfully fought against socialist education.
 UNAM supported the recognition of the academic certificates by Catholic preparatory schools, which validated their educational function.
 In an interesting turn of events, UNAM played an important role in the founding of the Jesuit institution in 1943, the Universidad Iberoamericana in 1943.
 However, UNAM opposed initiatives at the Universidad Iberoamericana in later years, opposing the establishment of majors in industrial relations and communications.

In 1943 initial decisions were made to move the university from the various buildings it occupied in the city center to a new and consolidated university campus; the new Ciudad Universitaria  (lit.
University City) would be in San Ángel, to the south of the city.
The first stone laid was that of the facult
Its founding  goes back to 1551, when Carlos I, King of Spain (Charles V, Emperor of the Holy  Roman Empire) decreed the foundation of the University of Mexico. The university was renamed on 22 September 1910 by Justo Sierra, then Minister of Education in the Porfirio Díaz regime, who sought to create a very different institution from its 19th-century precursor, the Royal and Pontifical University of Mexico, which had been founded on 21 September 1551 by a royal decree signed by Crown Prince Phillip on behalf of Charles I of Spain and brought to a definitive closure in 1865 by Maximilian I of Mexico. Instead of reviving what he saw as an anachronistic institution with strong ties to the Roman Catholic Church, he aimed to merge and expand Mexico City's decentralized colleges of higher education (including former faculties of the old university) and create a new university, secular in nature and national in scope, that could reorganize higher education within the country, serve as a model of positivism and encompass the ideas of the dominant Mexican liberalism.
The project initially unified the Fine Arts, Business, Political Science, Jurisprudence, Engineering, Medicine, Normal, and the National Preparatory schools; its first rector was Joaquin Eguía y Lis.
The new university's challenges were mostly political, due to the ongoing Mexican Revolution and the fact that the federal government had direct control over the university's policies and curriculum; some resisted its establishment on philosophical grounds. This opposition led to disruptions in the function of the university when political instability forced resignations in the government, including that of President Díaz. Internally, the first student strike occurred in 1912 to protest examination methods introduced by the director of the School of Jurisprudence, Luis Cabrera. By July of that year, a majority of the law students decided to abandon the university and join the newly created Free School of Law.
In 1914 initial efforts to gain autonomy for the university failed. In 1920, José Vasconcelos became rector. In 1921, he created the school's coat-of-arms: the image of an eagle and a condor surrounding a map of Latin America, from Mexico's northern border to Tierra del Fuego, and the motto, "The Spirit shall speak for my race". Efforts to gain autonomy for the university continued in the early 1920s. In the mid-1920s, the second wave of student strikes opposed a new grading system. The strikes included major classroom walkouts in the law school and confrontation with police at the medical school. The striking students were supported by many professors and subsequent negotiations eventually led to autonomy for the university. The institution was no longer a dependency of the Secretariat of Public Education; the university rector became the final authority, eliminating much of the confusing overlap in authority.
During the early 1930s, the rector of UNAM was Manuel Gómez Morín. The government attempted to implement socialist education at Mexican universities, which Gómez Morín, many professors, and Catholics opposed as an infringement on academic freedom.  Gómez Morín with the support of the Jesuit-founded student group, the Unión Nacional de Estudiantes Católicos, successfully fought against socialist education.  UNAM supported the recognition of the academic certificates by Catholic preparatory schools, which validated their educational function.  In an interesting turn of events, UNAM played an important role in the founding of the Jesuit institution in 1943, the Universidad Iberoamericana in 1943.  However, UNAM opposed initiatives at the Universidad Iberoamericana in later years, opposing the establishment of majors in industrial relations and communications.
In 1943 initial decisions were made to move the university from the various buildings it occupied in the city center to a new and consolidated university campus; the new Ciudad Universitaria  (lit. University City) would be in San Ángel, to the south of the city. The first stone laid was that of the facult
National Autonomous University of Mexico