I have been bearish on BP (LSE: BP.L) (NYSE: BP) since its Russian joint venture TNK-BP started to unravel. Compounded with that, the company faces unquantified liabilities from the Deepwater Horizon disaster in the Gulf of Mexico during 2010.

But BP has achieved something of a win in Russia with its deal with state-owned oil company Rosneft, and it seems likely that negotiations for a settlement of its U.S. liabilities are approaching their endgame. Once that happens, the company can start to refocus on its real business of exploring for, producing, and refining oil. The extraordinary risks should be reduced, and the shares rehabilitated as a consistent dividend-paying oil stock.

With a likely buyback program to buoy the shares, too, I reckon the long-term upside potential is starting to outweigh the short-term downside risk. And that puts the company firmly on my watch list, with a clear trigger for when I will buy.

Russia
BP's new Russian deal seems to be progressing well. The net result of the transaction is that the company will swap its 50% interest in TNK-BP for $12.3 billion cash and an 18.5% stake in Rosneft. When combined with BP's current 1.25% shareholding, that will give the FTSE firm 19.75% of Rosneft. Rosneft will also buy the other half of TNK-BP.

The definitive contracts were signed last week after the Russian government gave its approval. The transaction is expected to be completed early next year.

All this makes BP a very important player in Russia. And unlike under the firm's previous joint-venture structure, this time it is in bed with the government. Rosneft's chief executive, Igor Sechin, is a close associate of Russian president Vladimir Putin, and what the state-owned company does is closely aligned to the country's energy policy.

Back in January 2011 when BP agreed it share swap with Rosneft, the Russians were clearly looking for BP's expertise to develop the country's massive Arctic resources. It was maybe no coincidence that it was being courted less than a year after Deepwater Horizon had made the company extremely unpopular in the U.S.

So the relationship once thwarted can now be revived. Of course, it is not without risk: Nobody should believe that big business in Russia is transparent and played according to the Queensbury Rules. Those who are currently in power and in favor in Russia may not always be so. But BP's Russian risk is substantially less than it was.

U.S.
These developments come on top of the company's settlement of all its criminal charges in the U.S. That cost it $4.5 billion but was welcomed by the market for removing uncertainty.

Those damages will be dwarfed by the civil claims if BP is proved to be grossly negligent. In that case, the company could be fined up to $21 billion under the U.S. Clean Water Act, with other liabilities on top. Chances are, like the criminal law claims, the civil claims will be settled out of court at a much lower level.

But this is a "known unknown," as Donald Rumsfeld would have it. Once the potential U.S. liabilities are clarified, I shall be happy to invest in BP.

Buyback
As well as the $12 billion in cash that BP will get from Rosneft, the FTSE blue chip has agreed disposals which will generate $35 billion. The Rosneft transaction is dilutive and BP has indicated that it will take steps to compensate shareholders, which most analysts have interpreted to mean it will engage in a share buyback program.

That's unlikely to start until the U.S. liabilities are finally settled, and perhaps not until the Rosneft transaction is completed next year. When it does, it may give the share price something of a push.

Valuation
On a P/E of 7.3, BP is trading at an 11% discount to Royal Dutch Shell, but has a similar 5% yield. With the shares still down about a third from immediately prior to the Deepwater Horizon disaster, I feel there is room for them to move upwards.

It will be a change for BP to be valued as an oil stock, on the basis of its reserves and resources, exploration success, production, and efficiency rather than by the potential size of its downside risk. But it will then certainly merit a place in any oil and gas portfolio.

Let me finish by adding that, if you would like to know more about how to value oil and gas companies, or you want to invest in the sector but are unsure which stocks to pick, I recommend you read "How to Unearth Great Oil and Gas Shares." It's the latest free report from The Motley Fool, and it is packed full of investing help and suggestions. You can download the report straight to your inbox by clicking here.