On 1 July 2012, Mexico's presidential election took place. In an initial, partial count issued that night, the Federal Electoral Institute (IFE) announced that based on a fast vote counting, Peña Nieto was leading the election with 38% of the votes. His nearest competitor, Andrés Manuel López Obrador, was just 6 points behind him. The figures were meant to be a representative sample of the votes nationwide; but shortly after this announcement, Peña Nieto appeared on national television claiming victory. "This Sunday, Mexico won," he said. He then thanked his voters and promised to run a government "responsible and open to criticism." At the PRI headquarters in Mexico City, the victory party began. With more than 97% of the votes counted on election day, the PRI had won with about 38% of the votes, just 6.4 points above the leftist candidate López Obrador of the Party of the Democratic Revolution (PRD), who refused to concede to the results and had threatened to challenge the outcome.
Peña Nieto was sworn-in as President of Mexico on 1 December 2012 at the federal congress and later flew to a military parade to formally take control of the armed forces. During his inauguration speech at the National Palace, Peña Nieto proposed his agendas and reforms for the new administration. Before and after the inauguration, in an event that has been labeled by the media as the 1DMX, protesters rioted outside of the National Palace and clashed with Federal Police forces, vandalizing hotel structures and setting fires in downtown Mexico City. More than 90 protesters were arrested and several were injured. Mayor Marcelo Ebrard blamed anarchist groups for the violence. However, there is evidence that agents of provocation worked with the police, paid 300 Mexican pesos (about US$20) for their acts of vandalism, according to media reports. Photos show the vandals waiting in groups behind police lines prior to the violence. Previous protests had been entirely peaceful, but on this occasion, in apparent response to violence, the police fired rubber bullets. The day after his inauguration, Peña Nieto announced the Pact for Mexico, an agreement that he had struck with the leaders of the two other major parties at the time, Jesús Zambrano Grijalva of the Party of the Democratic Revolution and Gustavo Madero Muñoz of the National Action Party, about the government's goals for the next few years. On 1 December 2018, Enrique Peña Nieto left office and was succeeded by Andrés Manuel López Obrador.
In 2012, the president-elect emphasized that he did not support the involvement or presence of armed United States agents in Mexico, but considered allowing the United States to instruct Mexico's military training in counterinsurgency tactics. Beyond that, Peña Nieto promised that no other measures will be taken by the States in Mexico.
On 13 December 2012, a law was approved that included far-reaching security reforms. Mexico's Interior Ministry, greatly strengthened by the bill, was made solely responsible for public security. Part of Peña Nieto's strategy consists of the creation of a national police of 40,000 members, known as a "gendarmerie". The Economist reported that the gendarmerie would have an initial strength of 10,000, but the Washington Office on Latin America reported that it was reduced to 5,000 members and would not be operational until July 2014. The Interior Ministry announced that 15 specialized police units were being formed to exclusively focus on major crimes that include kidnapping and extortion, along with a new task force dedicated to tracking missing persons. Peña Nieto also proposed centralizing the sub-federal police forces under one command.
According to the Financial Times in 2012, Peña Nieto's PRI government, which held just over 38% of the votes in Congress, might have difficulty gaining a majority to pass such reforms, or the two-thirds majority needed to change the Mexican constitution. Pemex was founded through the nationalization of foreign oil interests, and the Mexican constitution bans major outside investments. Changing Pemex could transform the psychology of Mexico's business sector and involve cultural and political changes that cannot be rushed. President Lázaro Cárdenas seized foreign oil company assets in 1938 to form Pemex, which has served as a symbol of national identity.