Image copyright PA

Government finances showed an unexpected deficit in July for the second year running, according to official figures.

The Office for National Statistics said the deficit was £239m, missing many economists' forecasts for a small surplus.

For the financial year-to-date, borrowing was £37bn, up from £35.2bn in the April-to-July period last year.

July has historically been a month when tax receipts generate a surplus.

Tax receipts were higher than July last year, mainly due to an increase in VAT and income tax receipts.

However, payments of social benefits were also higher, mainly due to an increase in state pensions.

Nevertheless, the deficit fell from last year's July figure of £1.047bn.

Economists at Capital Economics said in a research note that, although the rise in total government borrowing to £37bn might "look bad", the comparisons with last year were distorted by tax changes.

"Tax receipts in April and May 2013 were boosted by individuals deferring income from earlier in the year to take advantage of April 2013's cut in the additional rate of income tax," the consultancy said.

A Treasury spokesperson said that the government was set to halve the deficit by the end of the year, in line with Budget forecasts.

"The government's long term economic plan is working, delivering economic security for hardworking people," the spokesperson said.

However, Labour's shadow Treasury secretary Chris Leslie claimed that "the figures confirm that George Osborne is set to break his promise to balance the books by next year".

Azad Zangana, European Economist at Schroders, told the BBC. "Despite the very strong economy we are seeing, the government is really struggling to get the public finances under control."