It was a tough week for the president, who seems to be trapped in a slow, downward spiral of unpopularity, with two more years left in his term and Mexico reeling from myriad problems including rampant corruption, resurgent homicide rates, a thriving drug trafficking industry, a sluggish economy and a plummeting peso.

The few voices of support for Mr. Peña Nieto — in political circles and among news commentators — have been drowned out by his detractors, and no more so than in the past week, when discontent over the gas price increase boiled over into protests and looting, setting off clashes with security forces that left several dead around the country.

The unrest comes as Mexico braces for the administration of President-elect Donald J. Trump, who has threatened to introduce far more restrictive immigration and trade policies, including canceling the North American Free Trade Agreement, increasing deportations and building a wall on the southern border of the United States.

Concern in Mexico about Mr. Trump’s planned tack on trade has been so great that he has been able to move the markets on the basis of his Twitter posts.

The Mexican peso hit record lows last week after he criticized General Motors on Twitter for exporting cars made in Mexico and Ford Motors announced that it would cancel plans for a $1.6 billion plant in the country. Mexico’s Central Bank was forced to intervene to bolster the peso, but the currency took another hit after Mr. Trump threatened Toyota on Thursday with a “big border tax” if it went ahead with a new factory in Mexico.