The government is claiming George Osborne's tough deficit reduction plan is working, after official figures on Friday showed a better than expected performance by the public finances last month.

With City analysts describing the year-on-year improvement in borrowing as a rare piece of good news amidst the gloom, the Treasury said ministers were determined to stick to the austerity plan.

Figures from the Office for National Statistics showed that the state coffers were back in the black last month, confounding City forecasts of a £500m deficit by registering a surplus of almost £2bn.

Net borrowing – excluding help for Britain's financial sector, the government's preferred yardstick of the public finances – was broadly in balance last month but £3.5bn down on July 2010.

"Today's figures continue to show deficit reduction taking effect with the public finances in balance in July, better than the market expected and better than last year, and tax receipts growing by 5.6% despite weaker North Sea and financial sector profits," a Treasury spokesman said.

"However, as recent weeks' events have shown with the US ratings downgrade and continued turbulence in Europe, it is vital that the government sticks to this plan."

The chancellor has announced tax increases and spending cuts in order to reduce Britain's deficit from its peak of £156bn hit in 2009-10.

Britain's independent Office for Budget Responsibility (OBR), set up by Osborne after the 2010 election, has predicted that public borrowing excluding government interventions to help UK banks will total £122bn in 2011-12.

Borrowing for the first four months of the 2011-12 financial year stood at £40bn, a £4bn improvement on the same period a year earlier, but analysts warned that the improvement was not sufficient to hit the OBR target.

"July's public finance figures suggest that the trend in borrowing has improved a bit, but not enough to leave the government on track to hit the fiscal forecasts for the year as a whole", said Samuel Tombs of Capital Economics.

On current trends Osborne was likely to miss the OBR's £122bn forecast by around £10bn.

John Hawksworth, chief economist at PricewaterhouseCoopers, commented: "Amid the thunderbolts hitting global stock markets in recent days, today's public borrowing figures provide a rare glimmer of light for the chancellor.

"After adjusting for special factors, it seems that tax revenues so far this year have been close to where the OBR projected them to be at the time of the budget in March."

Noting that there was a possibility of borrowing overshooting the OBR's £122bn target, Hawksworth added: "To the extent that this is a temporary cyclical phenomenon, it would not be a matter of concern, but if it indicates slower sustainable trend growth in the UK economy in the medium term, then it would be more serious."