Oil giant BP posted a first quarter loss, as the sharp decline in oil prices earlier this year took its toll on the industry, but the company retained its dividend.

In the three months to 31 March 2016, the FTSE 100-listed group posted a $485m (£334.5m,€430.3m) replacement cost (RC) loss, compared with a profit of $2.1bn a year ago. This was far less than the $3.3bn loss recorded for the final quarter of 2015.

After accounting for a post tax net charge for no operating items and unfavourable accounting effects, underlying replacement cost profit for the quarter was $532m, higher than the $196m recorded in previous quarter but significantly lower than the $2.6bn it posted in the corresponding period in 2015.

BP said that, compared with the previous quarter, lower costs throughout its operations more than offset the impact of significantly weaker oil and gas prices and refining margins. "Despite the challenging environment, we are driving towards our near-term goal of rebalancing BP's cash flows," said group chief executive Bob Dudley.

"Operational performance is strong and our work to reset costs has considerable momentum and is delivering results. Furthermore, development of our next wave of material upstream projects is well on track."

BP said its replacement cost profit in its downstream fell from $2.08bn to $1.88bn, while its upstream business swung to a $1.21bn loss from a $372m profit. Meanwhile, total production in the quarter increased 5.2% year-on-year to 2.43bn barrels of oil equivalent per day, although the company expects production to fall in the second quarter reflecting seasonality and maintenance activity on its assets.

Dudley, who revealed BP booked a net pretax charge of $917m in the period, which included costs related to the settlement for the Gulf of Mexico oil spill in 2010, said oil prices could return to 2015 levels by the end of the year.

"Market fundamentals continue to suggest that the combination of robust demand and weak supply growth will move global oil markets closer into balance by the end of the year," he said.

After slumping to multi-year lows earlier this year, crude oil prices have recovered about 60% over the last three weeks.