BP plc (BP - Get Report)  shares traded at the highest level in more than a month Tuesday after the group posted second quarter earnings that were largely in-line with forecasts and maintained its dividend as the group swung into profit thanks to gradually rising global oil prices.

BP said profits for the three months ending in June hit $144 million, a massive swing from the $1.42 billion loss recorded over the same period last year. So-called underlying replacement cost profits slipped 5% to $684 million, BP said, but still topped a company-provided consensus of $500 million 

Earnings per share came in at $0.04, the company said, matching the FactSet consensus and rising from a loss of $0.46 from the same period last year. Revenue hit $56.511 billion, up 21% from last year and firmly ahead of the FactSet estimate of $51.284 billion. The group said it will maintain its $0.10 per share dividend.

Watch More with TheStreet: