Europe's largest oil company by value Royal Dutch Shell plc (RDS.B - Get Report) on Thursday, July 27, posted earnings of $3.6 billion, beating analyst expectations of about $3.5 billion following a strong performance by the group's chemicals and refining operations.

Profit climbed to $1.55 billion, up 31% from $1.17 billion in the same quarter last year, but down on the first quarter figure of $3.5 billion. Free cash flow climbed to $12.2 billion, blitzing the $3.2 billion loss in the second quarter of 2016 and the $5.18 billion in the first quarter of this year.

"Cash generation has been resilient over four consecutive quarters, at an average oil price of just under $50 per barrel," CEO Ben van Beurden said in a statement. "This quarter, we generated robust earnings excluding identified items of $3.6 billion, while over the past 12 months cash flow from operations of $38 billion has covered our cash dividend and reduced gearing to 25%."

Oil companies had been expected to post strong year-on-year gains as oil prices had climbed about 8% higher in the second quarter compared to a year earlier. Comparisons with the first quarter of this year are likely to be less flattering as prices dipped 7%.

Those oil price movements were reflected in Shell's upstream business results, which posted earnings of $339 million over the second quarter, up from a $1.33 billion loss this time last year but down from the $540 million posted in the first quarter. Total production of oil and gas dipped quarter-on-quarter to 3.5 million barrels of oil equivalent per day, from 3.75 million in the first quarter.

The group's downstream refining and chemicals operations proved to be the star of the quarter. Downstream earnings for the three months to the end of June were $2.53 billion, up on last quarters figure of $2.5 billion and on Q2 2016's figure of $1.8 billion.

Operating expense crept higher in the quarter, coming in at $9.55 billion, compared to $9.3 billion in the first quarter.

Watch More with TheStreet: