President López Obrador wants to halt most oil exports and imports of gasoline and other fuels. Critics say he is reneging on Mexico’s climate change commitments.DEER PARK, Texas — Two giant murals, on storage tanks at an oil refinery here, depict the rebels led by Sam Houston who secured Texas’ independence from Mexico in the 1830s. This week those murals will become the property of the Mexican national oil company, which is acquiring full control of the refinery.The refinery purchase is part of President Andres Manuel López Obrador’s own bid for an independence of sorts. In an effort to achieve energy self-sufficiency, the president of Mexico is investing heavily in the state-owned oil company, placing a renewed emphasis on petroleum production and retreating from renewable energy even as some oil giants like BP and Royal Dutch Shell are investing more in that sector.Mr. López Obrador aims to eliminate most Mexican oil exports over the next two years so the country can process more of it domestically. He wants to replace the gasoline and diesel supplies the country currently buys from other refineries in the United States with fuel produced domestically or by the refinery in Deer Park, which would be made from crude oil it imports from Mexico. The shift would be an ambitious leap for Petroleos Mexicanos, the company commonly known as Pemex. The company’s oil production, comparable to Chevron’s in recent years, has been falling for more than a decade, and it shoulders more than $100 billion in debt, the largest of any oil company in the world.The decision to pay $596 million for a controlling interest in the Deer Park refinery, which sits on the Houston ship channel and would be the only major Pemex operation outside Mexico, is central to fulfilling Mr. López Obrador’s plans to rehabilitate the long-ailing oil sector and establishing eight productive refineries for Mexican use. Mexico also agreed to pay off $1.2 billion in debts that Pemex and Shell jointly owe as co-owners of the refinery, which is profitable.“It’s something historic,” Mr. López Obrador said last month. In a separate news conference last year, he said, “The most important thing is that in 2023 we will be self-sufficient in gasoline and diesel and there will be no increase in fuel prices.”While Mr. Lopez Obrador’s policies diverge from the rising global concern over climate change, they reflect a lasting temptation for leaders and lawmakers worldwide: replacing imported energy sources with domestically produced fuels. Further, the generally well-paying jobs the oil and other fossil fuel industries provide are politically popular across Latin America, Africa as well as industrialized countries like the United States.In the 1930s, the Mexican government took over Royal Dutch Shell’s operations south of the border as it nationalized the entire oil industry then dominated by foreigners. Now Mr. López Obrador is poised to go one step further, taking complete control of a big Shell oil refinery.The takeover is all the more pointed because it is happening in an industrial suburb that calls itself “the birthplace of Texas,” where rebels marched to the San Jacinto battlefield to defeat the Mexican Army — the event commemorated on the refinery murals. The battlefield is a five-mile drive from the refinery.It is hard to overestimate the connection between oil and politics in Mexico, where the day petroleum was nationalized, March 18, is a national holiday. Oil provides the Mexican government with a third of its revenues, and Pemex is one of the nation’s biggest employers, with about 120,000 workers. Mr. López Obrador hails from the oil-producing state of Tabasco, and the powerful Pemex labor union is a crucial part of his political base. He ran on a platform of rebuilding the company, and has raised its production budget, cut taxes it pays and reversed efforts by his predecessor to restructure its monopoly over oil production in the country.When he took office three years ago, Mr. López Obrador began undoing changes made in 2013 to the country’s Constitution intended to open the oil and gas industry to private and foreign investment. He is also pushing to reverse electricity reforms that his predecessor, Enrique Peña Nieto, put in place to increase the use of privately funded wind and solar farms and move away from state-run power plants fueled by oil and coal.Energy experts say Mexico is backtracking on a commitment it made a decade ago under President Felipe Calderón, to generate more than a third of its power from clean energy sources by 2024. Mexico now produces just over a quarter of its power from renewables.“They are going to heavier fuels rather than to lighter fuels,” said David Goldwyn, a top State Department energy official in the Obama administration. “Virtually every foreign company — Ford, Walmart, G.E., everybody who operates there — has their own net-zero target now. If they can’t get access to clean energy, Mexico becomes a liability.”Mr. López Obrador’s government has said it will combat climate change by investing in hydroelectric power and reforestation.Many of the Mexican president’s initiatives are being contested by opposition lawmakers and the business community. But Mr. López Obrador can do a lot on his own. He plans to spend $8 billion on a project to build an oil refinery in Tabasco state, and more than $3 billion more to modernize six refineries.President Andres Manuel López Obrador hails from the oil-producing state of Tabasco, and the powerful Pemex labor union is a crucial part of his political base.Gustavo Graf Maldonado/ReutersThe purchase of the Deer Park refinery is crucial to his plans because the Tabasco complex will not be completed until 2023 or 2024 and will not produce enough gasoline, diesel and other fuels to meet all of Mexico’s needs.Long a partner of Pemex, Shell, which operates the Deer Park refinery, is selling its stake in part to satisfy investors concerned about climate change who want the oil giant to invest more in renewable energy and hydrogen.Under Mexican ownership the refinery will continue its practice of using Mexican crude oil, but it will probably sell more of the gasoline and other fuels it produces to Mexico. In the future, some energy experts said, Pemex could also use the Deer Park refinery to process oil from other countries that also produce the kinds of heavy crude that Mexico does.“I think it’s a good deal and makes sense for Pemex,” said Tom Kloza, global head of energy analysis at Oil Price Information Service, who noted that Deer Park could perhaps process Venezuelan oil if the United States lifted sanctions against that country.The Mexican policy changes would have only a modest and temporary impact on American refineries, which can replace Mexican oil with crude from Colombia, Brazil, Saudi Arabia and Canada. Refiners could lose as much as a half-million barrels of transportation fuel sales a day to Mexico, but energy experts say refiners would be able to find other markets.Guy Hackwell, the general manager of the Deer Park complex, said, “Best practices will remain in place.” He said the “vast majority of the work force will report to the same job the day after the deal closes.”As for the murals, a Pemex spokeswoman, Jimena Alvarado, said, “We would never remove a historical mural.”Residents in Deer Park, in the heart of the Gulf of Mexico petrochemical complex, say they feel assured that locals will run the plant and Shell will continue to own an adjoining chemical plant. “The phone numbers will remain the same for who we contact in the event of an emergency and we will still have the same people and relationships, so I feel good about that,” Deer Park’s city manager, Jay Stokes, said.But some energy experts said Mr. López Obrador’s approach to energy, including the refinery purchase, would waste precious government resources that could be better used to reduce greenhouse gas emissions and local air pollution. There are also doubts that Mexico can build enough refining capacity to fulfill the president’s objectives.Shell, which operates the Deer Park refinery, is selling its stake in part to satisfy investors concerned about climate change who want the oil giant to invest more in renewable energy and hydrogen.Brandon Thibodeaux for The New York TimesJorge Piñon, a former president of Amoco Oil de Mexico, said Mexico most likely would not be able to immediately profit from slashing exports of crude and processing its own fuels since the refinery business typically has low profit margins, especially in Latin America.He said the Mexican refineries could not match American refineries in handling Mexico’s high-sulfur heavy crude. Mexican fuels made from heavy oil caused severe air pollution problems in many cities before the country began importing cleaner-burning American gasoline and diesel over the last 20 years.By exporting less oil, Mexico would also almost certainly use more of it for domestic power generation, potentially pushing out solar and wind generation and producing more air pollution and greenhouse gas emissions.“His nationalistic decisions will have a negative impact on climate change,” Mr. Piñon said. “He is marching back to the 1930s.”Mr. López Obrador is unapologetic. “Oil is the best business in the world,” he said at a news conference last May. More