Taxpayer-owned Royal Bank of Scotland has reported its first quarterly profit in a year and a half on the back of dramatic cost-cutting.

The troubled lender posted a profit of £259m ($334m) for the first three months of 2017 compared to a loss of £968m in the same period a year earlier.

Analysts had expected net profit to come in at around £50m for the first quarter.

The better-than-expected results were achieved on the back of strong performances in the UK retail and investment banking divisions, while operating expenses were reduced by £278m compared to the first quarter of 2016.

Shares in RBS opened 4% higher in London on the news.

The lender said in a statement that its cost-cutting plan was ahead of schedule and reaffirmed that it would post a full-year profit in 2018.

RBS has reported nine consecutive years of losses since the government spent £45bn to buy a majority stake in the bank in 2008.

"These results reflect very much what we talked about at full year," RBS chief executive Ross McEwan said.

"Firstly, a strong and improving core bank and secondly, fewer remaining legacy issues. Core income is up on last year, adjusted costs are down, and we're making better use of capital."

The banking group, which is 72% owned by the taxpayer, reported an adjusted operating profit of £1.37bn for the first quarter, well above expectations for a profit of around £940m.

"RBS has been quick off the blocks in 2017, with a strong performance that has comfortably beaten expectations," said Laith Khalaf, senior analyst at Hargreaves Lansdown.

"The UK retail bank appears to be chugging along quite nicely, and even the investment bank chipped in with some decent numbers.

"It's too early to pop the champagne corks though, because the US Department of Justice is likely to play the role of party pooper at some point by landing RBS with a massive fine."

RBS announced on 26 January that it would take a one-time charge of £3.1bn in order to pay a fine from the Department of Justice for mis-selling mortgage-backed securities during the financial crisis.

The lender, which has set aside a total of £6.7bn to pay fines, is still in discussions with US authorities over the size of the settlement.