The rating agency bumped BP up one notch to A1 and said the London-based company's outlook was positive. Moody's last upgraded BP's long-term issuer rating in 1998, a spokesman said.

"Our decision to upgrade BP to A1 factors in the increased clarity around the size and timing of remaining cash payments linked to the Deep Water Horizon incident, as well as expected improvements to BP's credit metrics and its strong operating performance despite high oil price volatility," said Elena Nadtotchi, vice president and senior credit officer at Moody's.

The settlement of the Deepwater Horizon fines and clean up costs in 2015 brought BP's pretax bill to more than $62 billion. The company will pay the charge gradually into the 2030s.

BP, like other oil companies, slashed spending and costs in the wake of a sharp drop in oil prices from mid-2014. It is aiming to be able to general cashflow at oil prices of $35-$40 a barrel by the end of the decade.

"BP demonstrated strong operating performance amid high volatility in oil prices," according to Moody's.

It is set to see a sharp rise in production in the coming years as it starts up eight projects this year, including in Oman and Azerbaijan, the largest number in the company's history in a single year.

The company hopes to add 800,000 barrels per day of new production by the end of the decade.

"The positive outlook recognises that BP's strong business profile may sustain a higher rating and anticipates that the company will continue to deliver strong operating performance in 2017-19, supported by growth and improving profitability of the upstream, and rising contribution from the downstream," Moody's said.

Of 29 analysts surveyed by Reuters, 14 have 'buy' or 'strong buy' recommendations on BP, and 14 a 'hold' recommendation.

BP's debt at the end of March was $28.6 billion, which represents 28 percent of the company's equity capital, also known as gearing.

(Reporting by Ron Bousso; Editing by Mark Potter)

By Ron Bousso