MEXICO CITY — He was the son of a petroleum worker in a nation that honors its oil company with an annual holiday. When Andrés Manuel López Obrador became president, he made it a priority to revive Pemex.

Mexico’s state-owned energy giant, the second-largest company in Latin America, had served in the past as a wellspring of funds for the government and the nation’s development. López Obrador hoped to harness it to spur Mexico’s economic revival and lift people out of poverty.

Now those plans have hit the skids.

Pemex’s bonds have tumbled into junk status after downgrades by major ratings agencies, including a thumbs-down from Moody’s this month. Then came the coronavirus and the worldwide collapse in oil prices, with futures trading in negative territory.

Instead of boosting Mexico’s growth, Pemex could become a crushing financial burden for a nation that was already facing its worst recession in decades.

“Everyone knows [López Obrador] will not let Pemex go under,” said Francisco Monaldi, a professor of energy economics at Rice University in Houston. “He will drag the Mexican government down with Pemex.”

Mexican officials say they believe the economic damage to Pemex — and the government — can be contained. In normal times, Pemex produces at least 15 percent of the government’s annual revenue. Authorities say they have shielded those tax payments through a complex hedging operation that will allow them to sell some Mexican oil at $49 a barrel — rather the $8.50 it fetched last week. And López Obrador says Mexico will ride out the price decline by turning more of its oil into gasoline in domestic refineries.

But oil analysts, ratings agencies and academics say the company’s outlook remains dire, as the coronavirus pandemic dries up global demand for oil.

“At some point there comes a reckoning, and I think it comes this year,” said David Shields, an oil consultant in Mexico City.

Pemex, short for Petróleos Mexicanos, has never been just an oil company. It was formed in 1938 after the government kicked out foreign petroleum companies, which it said were exploiting Mexico’s natural resources and workers. The act is commemorated in a public holiday every March. For years, the company was a sociopolitical arm of the state, making payments to federal and local governments, building schools, providing jobs.

To López Obrador, a longtime leftist who grew up in oil-producing Tabasco state, Pemex is as much a part of Mexico’s identity as the army or the ancient Mayan pyramids.

“Forget about privatization,” the president told workers at a Pemex refinery in the southern city of Salina Cruz a year ago. “You are going to be the main protagonists in rescuing Pemex — and rescuing the nation.”

Turning the company around would have been a gargantuan task, though, even without the crash in oil prices.

When López Obrador took office in December 2018, Mexico’s crude oil production had nose-dived to about 1.8 million barrels a day. That’s about half of what Pemex pumped in 2004, when it was Latin America’s biggest company. (It has since been overtaken by Petrobras, its Brazilian competitor.)

Pemex had been battered by years of mismanagement, anemic investment and low oil prices.

López Obrador, widely known by his initials, AMLO, set ambitious goals: He pledged crude production would increase by 50 percent by 2024, that Mexico would become self-sufficient in gasoline, that Pemex’s onerous debt would be tamed.

But the company has made little progress.

Pemex remains the world’s most indebted major oil company. It owed $105 billion to financiers at the end of 2019, just a slight improvement over the previous year. Crude output dipped last year to about 1.7 million barrels per day.

One of Pemex’s main problems is that it has exhausted the giant oil fields that were once easy to drill, such as Cantarell, off the southern state of Campeche. That site was discovered in the early 1970s after a fisherman complained to Pemex about the black gunk coating his nets. It became, for a time, the second highest-producing field in the world.

Mexico still has oil, but it is believed to be largely in deep water or shale, which require more-sophisticated technology and are more expensive to develop. Pemex, though, is squeezed for cash.

López Obrador has suspended new partnerships with private firms, which became possible under a reform of the state oil monopoly championed by his predecessor, Enrique Peña Nieto. “The era of privatization is over,” López Obrador said last month.

And after the credit downgrades by Moody’s Investors Service and Fitch Ratings, it will probably be more expensive for Pemex to borrow.

López Obrador’s government has injected billions of dollars into Pemex, eased its heavy tax burden and restructured its debt. It has also tried to tackle corruption, an endemic problem. Emilio Lozoya, the head of Pemex from 2012 to 2016, was indicted on corruption charges last year. He now sits in a Spanish jail, awaiting possible extradition to Mexico. (Lozoya says he is innocent.)

Pemex has identified 20 high-priority fields where it intends to drill. Analysts say they are unlikely to boost production significantly.

“AMLO came in and thought somehow Pemex would magically take off,” Shields said. “He didn’t have any realistic business ideas.”

The president clearly sees Pemex as more than a business. After taking office, he had the oil company adopt the slogan: “For the recovery of sovereignty.”

López Obrador said it was “shameful” that nearly three-quarters of Mexico’s gasoline comes from U.S. refineries. He is planning to refurbish Mexico’s aging refineries and build a new one, at a projected cost of $8 billion.

This would not only create jobs, he says — “it’s an issue of national security.”

“Imagine if [the U.S. government] declared a blockade,” he said during a visit to a Pemex refinery in northern Mexico last year. “How long would a government last, if there were no gasoline?”

Analysts say it’s cheaper to refine Mexican oil in the United States, which has bigger, more-efficient facilities.

López Obrador said last week that Mexico’s Finance Ministry had protected the tax revenue it expected to receive this year from Pemex by hedging the price of oil. The country would get through the current downturn by temporarily shutting some of its newer fields and steering more of its crude into domestic refineries, he said.

“We’re going to produce ever more gasoline in Mexico, until we’re self-sufficient,” he told reporters on Friday.

Most of the company’s oil is not hedged, however, and will be sold at market prices.

“Obviously this is a great political speech,” said Gonzalo Monroy, managing director of the GMEC consultancy. “But economically, Pemex is going to have massive losses.”

If that’s the case, Pemex could suck up even more government aid. Fitch said the oil company required “extraordinary and proactive government support.” Mexico, though, is already facing what could be its worst recession in decades, with an expected economic contraction of up to 8 percent.

“Pemex, instead of becoming a source of revenue for the government, is actually becoming an even heavier drain,” said Duncan Wood, director of the Mexico Institute at the Washington-based Wilson Center. “We’re getting the exact opposite of what AMLO thought would happen.”