The rise in the price of oil since its $28 per barrel low earlier this year has caught many investors by surprise. After all, there’s still a major demand/supply imbalance and it appears as though this situation will remain in place over the medium term.

This causes a real headache for investors in BP (LSE: BP) and other oil and gas plays, since investor sentiment has improved but could easily weaken moving forward.

On the one hand, the long-term prospects for oil remain sound. Demand from emerging markets in particular is expected to rise and while cleaner options will become available, fossil fuels are likely to remain a key part of the energy mix over the coming decades.

However, on the other hand, there’s a glut of oil and it wouldn’t be unreasonable to state that the price of oil could return towards its 2016 lows in the coming months. In such a situation, the profitability of oil companies such as BP (and their share prices) could tumble.

The key focus is therefore on a margin of safety. In other words, the price of oil is a known unknown, so it seems logical to seek out companies that are trading at a discount to their intrinsic value since they may offer less downside and greater upside potential.

Fair price?

On this front BP seems to have considerable appeal. It may trade on a price-to-earnings (P/E) ratio of almost 29 at the present time, but with its pre-tax profit forecast to rise from £2.9bn in the current year to as much as £6.8bn in 2017, its rating is due to fall to just over 13 next year. For an oil and gas major that has a well-diversified asset base and potential to build on its market share in the long run, this appears to be a very fair price to pay.

In addition, the market seems to be pricing-in a dividend cut which, based on current forecasts, isn’t set to take place. For example, BP currently has a yield of 7.4%, which is exceptionally high and would normally indicate that a dividend cut is round the corner. However, with BP’s dividends expected to be fully covered by profit next year, BP’s shareholder payouts may remain relatively resilient and robust over the medium term.

Certainly, BP’s dividends are highly dependent on the price of oil. If the price of black gold falls heavily then it seems likely that shareholder payouts will also fall. However, with such a high yield as well as a relatively appealing rating and upbeat growth forecasts, BP seems to have a sufficiently wide margin of safety to merit investment at the present time.

So, while BP could be set to slump or soar based on how the oil price moves in the coming months and years, from a risk/reward perspective it has considerable appeal for long-term investors.

Despite this, there's another stock that could be an even better buy. In fact it's been named as A Top Growth Share From The Motley Fool.

The company in question could make a real impact on your bottom line in 2016 and beyond. And in time, it could help you retire early, pay off your mortgage, or simply enjoy a more abundant lifestyle.

Click here to find out all about it - doing so is completely free and comes without any obligation.

Peter Stephens owns shares of BP. The Motley Fool UK has recommended BP. We Fools don't all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors.