Government borrowing hit £22.3bn in October as the UK continued heavy spending to support the economy during the coronavirus pandemic.
The figure, £10.8bn more than for the same month last year, is the highest October borrowing total since monthly records began in 1993.
Borrowing makes up the shortfall between spending by the government and the amount received in taxes.
Tax receipts were £39.7bn last month, down £2.7bn from a year ago.
So far this tax year, government borrowing has reached £214.9bn, £169.1bn more than in the same period last year.
The ONS said the coronavirus pandemic had had a “substantial effect” on public sector borrowing, which it estimated could reach £372.2bn by the end of this financial year in March.
The Office for Budget Responsibility will publish its latest forecast next week, when Chancellor Rishi Sunak, announces his Spending Review.
Millions of public sector workers face a pay freeze as part of that review, as the chancellor makes the case for pay restraint to reflect a fall in private sector earnings this year.
The Treasury is trying to bolster public finances after the huge rise in spending to fight coronavirus.