BP also increased cash flow from operations in a further sign that efforts by top oil companies to cut costs since the 2014 price slump are paying off as it expects oil prices to hold at around $50 a barrel into next year.

"We continue to position BP for the new oil price environment, with a continued tight focus on costs, efficiency and discipline in capital spending," Chief Executive Bob Dudley said in a statement.

BP shares were up 3.4 percent at 0804 GMT, outperforming the broader sector index <.SXEP>, which was up 1.2 percent.

At the same time, BP saw its debt pile rise to nearly $40 billion as it invests in bringing projects online and continues to pay off its bill relating to the deadly 2010 Deepwater Horizon rig explosion in the Gulf of Mexico.

Gearing, the ratio between debt and BP's market value, rose to 28.8 percent by the end of June from 24.7 percent a year earlier.

Despite the sharp slowdown in the sector's activity since prices halved three years ago, BP is set to launch seven oil and gas projects in 2017 -- the largest number in a single year in its history.

BP's production was up 9.9 percent from a year earlier at 2.431 million barrels of oil equivalent per day helped by some of the new start-ups.

They include the Quad 204 oilfield, one of the largest projects in the North Sea in recent years which BP launched in May after a $5.7 billion redevelopment.

BP said its oil and gas production will be broadly flat in the third quarter as further project start-ups outweigh the impact of maintenance.

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

Chief Financial Officer Brian Gilvary told Reuters BP's 2017 capital spending was expected to be around $16 billion, in the middle of the forecast range.

Banco Santander analyst Jason Kenney said he saw "optimism that BP could move forward with more robust delivery than currently expected in 2H17 and going into 2018".

BP's quarterly underlying replacement cost profit, the company's definition of net income, came in at $684 million, topping the $500 million forecast in a company-provided analyst consensus.

That was down from $720 million a year earlier and $1.51 billion in the first quarter.

The results were impacted by a $750 million charge for unsuccessful exploration campaigns in Angola.

BP's operating cash flow, excluding payments related to the Gulf of Mexico oil spill, rose in the second quarter of the year to $6.9 billion from $5.3 billion a year earlier.

BP's operating cash flow, including payments related to the spill, rose to $4.9 billion in the first quarter of the year from $3.9 billion a year earlier.

Payments related to the Gulf of Mexico settlement are set to reach $4.5 billion to $5.5 billion in 2017 before falling to $2 billion in 2018. BP has so far paid a pre-tax total of $63.214 billion in clean up costs and penalties.

(Reporting by Ron Bousso; editing by Jason Neely and Susan Thomas)

By Ron Bousso and Karolin Schaps