The ONS said the public sector finances excluding bank bail-outs - the government's preferred measure - showed a deficit of £600m, compared to a £2.8bn surplus in July 2011, following a sharp shortfall in corporation tax.
July is traditionally a month for strong income tax and corporation tax receipts and economists had been expecting a surplus of £2.2bn.
However, total receipts fell 0.8pc, driven by a near 20pc drop in corporation tax, while Government spending increased 5.1pc.
Revenue from North Sea oil and gas companies was unusually low and accounted for about £1bn of a £1.7bn shortfall in corporation tax compared to last year.
In a further blow to the Chancellor, net borrowing for April to June, was revised up by £1.4bn.
It now looks certain that Osbrone's borrowing treats are going to be wildly overshot this year. Plan A is failing badly now, as many on the left long predicted.
But what's also worrying is that corporation tax data: if profits are collapsing then whatever is happening with regard to employment at present the fall in profit will remove any incentive they have to invest and the inevitable consequence will be a spiral of decline unless the government intervenes with strong programmes of direct investment.