Image copyright Getty Images

The government's finances were in surplus by £2bn last month, the biggest surplus for July in 18 years, official figures show.

The figure was up from a surplus of £1bn a year ago.

At the same time, borrowing in the April-to-July period fell to its lowest level since 2002.

Analysts said the reduction in borrowing should give Chancellor Philip Hammond extra money to play with in the Budget this autumn.

Borrowing for the financial year so far has reached £12.8bn, £8.5bn less than in the same period in 2017, the Office for National Statistics said.

Public sector net debt, excluding public sector banks, was £1,777.5bn, equivalent to 84.3% of GDP. That is £17.5bn higher than a year earlier, but lower as a percentage of GDP than in 2017, when it was 86%.

Analysis:

Andy Verity, economics correspondent

July is usually a good month for the Exchequer. Because self-employed people make the second of two self-assessed tax payments in July, the chancellor tends to enjoy more money flowing in than flowing out in spending. But last month was the biggest surplus in 18 years.

Since the start of the financial year, the public sector - government, local government and other publicly owned corporations - has only had to borrow £12.8bn to plug the gap between its income and its spending. That is the lowest borrowing since 2002 - enough to encourage opponents of austerity to question if it is still necessary.

Those who want to keep austerity will point out that the debt - all the accumulated deficits of the past - is still very high by the standards of recent decades. And it's climbing. However, their opponents might retort, it's shrinking as a proportion of the economy. Other things being equal, that means it should be getting easier, not harder to manage.

'Sharp downward trend'

The public finances are prone to surpluses in July because of money coming in from self-assessed income tax returns.

Last month, receipts from self-assessed income tax were £9bn, an increase of £1bn on July 2017. That is the highest level of July self-assessed income tax receipts since records began in 1999.

Over the financial year to March 2019, the Office for Budget Responsibility (OBR), which produces the official government forecasts, expects the public sector to borrow £37.1bn.

That amounts to about one-quarter of what it borrowed in 2009-10, at the peak of the financial crisis.

"Public borrowing has remained on a sharp downward trend, creating scope for the chancellor to pause the fiscal consolidation next year and still meet his self-prescribed targets," said Samuel Tombs, chief UK economist at Pantheon Macroeconomics.

"If this trend persists, borrowing will total just £23.7bn this year, much less than the £37.1bn forecast by the OBR in the Spring Statement."

Ruth Gregory, senior UK economist at Capital Economics, was more cautious, pointing out that "an undershoot of this magnitude is unlikely".

She added: "The recent improvement has been partly due to temporary factors, such as the timing of gilt issuance and redemptions."

However, she said Mr Hammond "should be able to deliver the extra funds for the NHS without compromising his fiscal target or having to find savings elsewhere".

A Treasury spokesman said great progress had been made repairing the public finances, but added: "Government borrowing is down by three-quarters and debt is due to begin its first sustained fall in a generation, but we cannot be complacent."

Shadow chancellor John McDonnell said: "The chancellor has passed on the deficit to his colleagues in other departments.... hard-pressed families and underpaid public sector workers have been made to pay for the price of Tory failure on the economy, with brutal cuts to social provision and relentless pay restraint."