According to the Office for National Statistics, borrowing to cover the gap between spending and revenue was £600m for July.
There was a surplus of £2.8bn in the same month a year earlier.
The Treasury blamed disappointing corporation tax receipts for the shortfall.
The Office for Budget Responsibility, the official UK economic forecaster, said there was still “significant uncertainty” about the outlook for borrowing this year.
Four months into the financial year the government has borrowed £44.9bn, £9.3bn higher than the same period in 2011.
That excludes banking interventions and the one-off boost in April from a transfer of Royal Mail pension assets to the public sector.
The OBR had predicted that borrowing on the same measure would be £120m for the whole of the financial year, down from the £125m borrowed last year.