Sometimes holding on to a stock that is getting whipped in the market needs a lot of patience and guts. The urge to offload a falling stock despite sound underlying fundamentals is something that even the greatest of investing gurus (read: Benjamin Graham and Warren Buffett) have warned against. Intelligent investors, on the contrary, see it as an opportunity to accumulate a few more shares of that stock at a cheap price.

The fall and the subsequent rise
Back in June, crude oil had nose-dived 27%, thanks to an impending European debt crisis. Fears of Greece backing out of the European Union threw global markets into turmoil causing the West Texas Intermediate to plunge from $106 a barrel to less than $78 a barrel -- all in a matter of seven weeks. Not surprisingly, plenty of oil and gas stocks took a dive. However, it was just a matter of time before the fundamentally sound businesses recovered. Among them, recently spun-out independent refiner Marathon Petroleum (NYSE: MPC) not only managed to weather the European storm, but has been an admirable path to recovery.

To put the entire thing into perspective, Marathon's stock has been up a whopping 51% since June after it had slid 23% between mid-March and early June. And the best part? Since the turn of this year, Marathon is already up a solid 55%! In other words, the debt crisis and the ensuing drop in the refiner's stock price was an excellent opportunity for the discerning investor to grab a few more shares.

What makes Marathon tick?
Back in June, I spoke about the Findlay-based refiner's strong cash position and strategically located refineries as the primary reasons behind the strong fundamentals. Its six-plant refinery network, located in the Midwest, Gulf Coast and Southeast regions, has the capacity to process significant amounts of the cheaper sour crude oil -- in other words, the WTI variant -- as against the more expensive Light Louisiana Sweet. The LLS variant tracks the internationally traded Brent crude. As long the spread between WTI and Brent prices exist, Marathon should be able to source its crude oil cheaply. Currently, the spread is around $18 per barrel with no obvious signs of narrowing.

Additionally, the recent fall in crude oil prices has benefited the refiner's gross margins in the second quarter. While this might not be a sustained phenomenon, it's worth mentioning.

Operationally and financially sound
With a refining capacity of nearly 1.2 million barrels per day, the capacity utilization is at almost 100%. This is among the highest in the industry. In fact, Marathon has been the only refiner to tap the Strategic Petroleum Reserve of 1 million barrels after a shortfall in output following Hurricane Isaac. This only underlines Marathon's operational prowess. The affected refineries were back to full capacity within a few days.

Moreover, the expansion of the heavy oil refining unit in Detroit is almost complete and should come on line later this year.

From a financial standpoint, Marathon has generated free cash flow of $1.1 billion in the 12 months ended June 30, and has a cash balance of $1.9 billion. These numbers should alone speak to the refiner's financial soundness. Also, its debt-to-equity ratio stands at a healthy 32%.

How cheap is the stock?
In valuation terms, Marathon looks pretty attractive. Here's how it stacks up against its peers:

Company

Trailing P/E

Forward P/E

Marathon Petroleum 7.4 5.9
Western Refining (NYSE: WNR) 14.7 6.1
Valero Energy (NYSE: VLO) 11.0 7.3
Tesoro (NYSE: TSO) 8.6 7.9

Source: Morningstar Financials.

Marathon seems to be the cheapest around with an attractive forward valuation as well. With a trailing industry P/E of 11.5, the market seems to be grossly underestimating Marathon's potential. With a respectable dividend yield of 2.12%, I find the long-term prospects of this stock pretty attractive.

Foolish bottom line
People tend to panic when the market takes a beating. However, the smarter investors will see opportunity here -- provided they do thorough research and analyses of the stocks they buy. If Marathon Petroleum sounds interesting to you, we will help you stay up to speed about its latest developments and analyses. All you need to do is add the company to your watchlist.