Devon Energy (DVN 1.51%) has taken a beating over the past year. Shares of the oil company currently sit about 35% below their 52-week high. Higher costs and lower oil prices have weighed down the stock.

That sell-off looks like a good buying opportunity. At least that's what an analyst at venerable Wall Street investment bank Goldman Sachs thinks, leading them to upgrade the bank's rating on the oil stock to a buy. Here's a look at what fueled the upgrade and whether investors should buy into the thesis. 

Drilling down into the Goldman upgrade

Goldman Sachs analyst Neil Mehta recently upgraded shares of Devon Energy from neutral to buy. Despite that upgrade, the analyst did trim their price target from $63 per share to $58. That still implies about 14% upside potential from the recent trading price. 

Devon's valuation is the big factor driving the upgrade. Mehta believes it's attractive, especially compared to its larger peers. The analyst also pointed to lower raw material costs as another catalyst. 

The analyst believes Devon Energy's sell-off has pushed its valuation to a compelling level. Mehta pegs Devon Energy's free cash flow yield at around 10% this year, putting it at a slight discount to its peers, which trade at about a 9% free cash flow yield on average. Meanwhile, the Goldman Sachs analyst sees Devon trading at about a 13% free cash flow yield based on their forecast for 2024-2026. That's cheaper than the analysts' projection that its peers trade at about an 11% forward free cash flow yield. 

One factor driving the analysts' improved view of Devon's free cash flow is the expectation that the headwinds impacting its capital spending are starting to wane. Inflation had driven up raw materials and service costs this year, pushing up capital spending at the expense of free cash flow. However, these cost pressures should fade with inflation beginning to cool off.

Showcasing their conviction

Mehta isn't the only one who believes Devon Energy stock is a buy. The oil company's management team completely agrees with that view. CEO Rick Muncrief stated on the first-quarter conference call:

We continue to see attractive value in repurchasing our shares, which we believe traded a significant discount to our intrinsic value. To capitalize on this compelling opportunity, we made substantial progress advancing our buyback program by repurchasing $692 million of shares year to date. In addition to our corporate buyback activity, multiple members of our management team, myself included, have also demonstrated their conviction in Devon's value proposition by purchasing stock in the open market over the past few months. With our board of directors approving the upsizing of the capacity of our repurchase program by 50% up to $3 billion, the company is well equipped to be active buyers of our stock over the course of the year. 

As the CEO pointed out, Devon Energy has been repurchasing shares hand over fist because management believes the stock trades at an attractive valuation. They further showcased that conviction by personally buying shares and getting the board of directors to approve a 50% increase in the repurchase authorization so they could buy back more shares.  

Given the company's current valuation, the buyback is having a meaningful impact on its outstanding shares. Devon is on pace to retire about 9% of its outstanding shares as it completes its $3 billion buyback program.

An attractive opportunity

Devon Energy's stock has tumbled due to lower oil prices and higher capital spending, which has squeezed its free cash flow. As a result, the company's variable dividend has steadily headed lower.

However, as the Goldman Sachs analyst pointed out, the market seems to have pushed shares down too far since it now trades at a discount to its peers. Because of that, now looks like a compelling buying opportunity, which Devon Energy is working hard to capitalize on by buying back a boatload of shares. That meaningful repurchase program adds to its investment appeal. Meanwhile, despite several cuts, Devon still offers a compelling dividend. Add in its upside potential to higher oil prices, and it's hard not to agree with Goldman Sachs and Devon's management team that shares look like a buy right now.