(Bloomberg) -- Analysts at Wall Street’s biggest banks say now’s the time to buy Exxon Mobil Corp. as rallying oil and gas prices increase the chances of the company being able to keep its highly prized dividend, the third-highest in the S&P 500 Index.

JPMorgan Chase & Co. on Wednesday joined Morgan Stanley, Goldman Sachs Group Inc. and Well Fargo & Co. in upgrading Exxon to ‘buy’ in recent weeks. Years of underperformance have left the stock trading at low valuations compared with peers, leaving it well-placed to gain from this year’s recovery in commodity prices, they said.

In the short term, higher oil and gas prices will give Exxon a much-needed cash injection to help pay its dividend, which the oil giant had been funding with increased debt for the past few quarters. Furthermore, Exxon’s “capital discipline is improving” after years of wasteful spending, JPMorgan’s Phil Gresh said as he upgraded the stock for the first time in seven years.

“Our struggle with recommending XOM has run the gamut, from full valuation in 2014-16, to lack of capital discipline in 2017-19, to lack of defense during the COVID-19 synchronized downturn in 2020,” he said. “As we sit here today, we think that the bar is materially lower, execution might finally be turning a corner.”

Last year, Exxon suffered a 41% drop, the worst annual performance in 40 years, as the oil giant lost its historic resilience to market downturns. Coming into the pandemic, investors had viewed Chief Executive Officer Darren Woods’s $210 billion seven-year counter-cyclical growth plan as leaving the company financially stretched. Once it hit, Exxon had nowhere to hide, forcing it to aggressively slash spending and jobs.

Some analysts have speculated Exxon would also be forced to cut its $15 billion-a-year dividend. But Morgan Stanley said Tuesday those fears may be overstated.

“Proactive cost and capex cuts coupled with rebounding commodity prices and downstream and chemical margins support outsized rate of change in free cash flow and dividend cover,” analysts led by Devin McDermott said.

Since Pfizer Inc. announced the first successful Covid-19 vaccine trials on Nov. 9, Exxon has climbed 31%, matching the gain in the S&P 500 Energy index. The higher stock price will come as welcome relief to management, which came under attack from activist investors Engine No. 1 and D.E. Shaw & Co. last month for poor returns and failing on climate.

Longer term, the analysts questioned whether Exxon may have to do more to address the energy transition, despite new emissions targets announced last month.

“Long-term secular risks remain including ESG pressures, questions about resource value as electric vehicles/energy efficiency gains momentum, refining oversupply and below-market returns on capital,” Goldman said in a Dec. 15 note. “That said, we see these as well priced into the valuations here.”

©2021 Bloomberg L.P.