His National Regeneration Movement (MORENA) and its allies fell nearly 60 votes short of the two-thirds majority needed in the 500-seat lower house of Congress, mustering just 275 votes after a raucous session that lasted more than 12 hours.
eeking to roll back previous constitutional reforms that liberalized the electricity market, Lopez Obrador's proposed changes would have done away with a requirement that state-owned Comision Federal de Electricidad (CFE) sell the cheapest electricity first, allowing it to sell its own electricity ahead of other power companies.
Under the bill, the CFE would also have been set to generate a minimum of 54% of the country's total electricity, and energy regulation would have been shifted from independent bodies to state regulators.
The contentious proposals faced much criticism from business groups and the United States, Mexico's top trade partner as well as other allies who argued it would violate the regional trade deal, the United States-Mexico-Canada Agreement (USMCA).
Lopez Obrador had argued the bill would have protected consumers and made the country more energy independent, saying the legislation was vital to his plans to "transform" Mexico.
Although the odds were against his party, he came into the vote seeking to leverage his victory in last weekend's referendum on his leadership.
Speaking ahead of the vote, Jorge Alvarez Maynez, a lawmaker from the opposition Citizens' Movement party, said the proposals, if enacted, would damage Mexico.
"There isn't a specialist, academic, environmentalist or activist with a smidgen of doubt - this bill would increase electricity prices, slow the transition to (clean) energy in our country and violate international agreements," he added.
The bill also contained a provision to nationalize lithium resources.
Lopez Obrador said this week that if the bill was defeated, he would send another bill to Congress on Monday aiming to have at least the lithium portion of the proposed legislation passed.