The civil trial of BP (BP 1.01%) stemming from the tragic 2010 rig explosion and resulting oil spill in the Gulf of Mexico has officially resumed, which likely couldn't come soon enough for the company's shareholders. Uncertainty over how badly BP would be penalized has kept a lid on BP's valuation over the last three years.

BP has already paid billions in penalties related to the spill, but billions more are at risk, depending on the results. All eyes are on the civil trial, and while there's a lot of money at stake, BP might just be a buy anyway.

Billions paid, and billions more to come
BP faces up to $18 billion in penalties if found guilty of gross negligence and if 4.2 million barrels spilled into the Gulf. If BP is not found guilty of gross negligence and its assertion that a lower amount of oil spilled is upheld, the tab will be closer to $3 billion. Clearly, there's a big difference between $3 billion and $18 billion, which makes a reasonable estimation difficult.

Meanwhile, the other companies involved in the spill are very much back to business-as-usual.Transocean (RIG 2.47%), the owner of the Deepwater Horizon rig that exploded, has paid much more modest penalties than BP. Transocean pleaded guilty to violating the Clean Water Act and was forced to pay $400 million, in addition to other penalties, earlier this year.

However, Transocean has more than enough financial ability to recover, as its underlying business has gotten back on track. Revenue is up 3.5% over the first half of the year, and the company booked more than $1 billion in operating profit over the first six months alone. Going forward, it will very much be business as usual for Transocean. That's because, due to the steady growth in global offshore drilling, Transocean has a huge $27 billion in contract order backlog.

Ditto for oil contractor Halliburton (HAL -0.92%), which provided cement used in construction of the well. Halliburton received little more than a slap on the wrist when it pleaded guilty to shredding pivotal computer test results, which resulted in a $200,000 fine. Clearly, Halliburton's investors have completely dismissed any adverse effects from the trial: Halliburton trades for 24 times trailing earnings and last year brought in more than $14 billion in revenue over the first half of the year alone.

As a result, it's clear BP has the most to risk. Which stands to reason, of course, since BP was the operator of the rig that exploded. In times like these, I usually prefer to err on the side of caution. Let's assume the worst-case scenario unfolds: that BP is indeed found grossly negligent, that 4.2 million barrel of oil spilled into the Gulf, and that the company is forced to pay the full $18 billion in damages. To date, BP has paid $42 billion in penalties, and assuming another $18 billion added on, the total bill would be $60 billion.

Believe it or not, here's why BP may actually be a buy
$60 billion is surely a huge sum, and would represent a massive liability for any company, even one the size of BP. At the same time, a relatively simple back-of-the-envelope analysis might actually present a bullish case for BP. Consider that since the spill, BP has lost roughly $18 per share, or approximately $55 billion in market value based on its 3.1 billion shares outstanding.

Therefore, you could actually make the argument that BP may be undervalued. Even when using the worst-case scenario, more than 90% of BP's likely total penalties are already priced in to the stock. And, of course, there's always the possibility that BP won't have to pay anything close to $18 billion in civil penalties, should the trail produce a more favorable verdict for the company.

Plus, it's helpful to remember that the market loves certainty above all. Finally removing the cloud of uncertainty hanging over BP's head these past three years will at long last allow the market to move on once and for all, and a higher earnings multiple for the stock wouldn't be out of the question. Not to mention, BP's 5.25% dividend yield provides a nice dose of downside protection, meaning you'll at least be paid well to wait for the market to reward BP with a higher valuation. As a result, despite the prospect of billions more in fines coming down the pike, investors may be wise to hold their noses and buy BP.