Government borrowing was £3 billion higher than expected in the year to July, putting pressure on the next chancellor to keep costs down to meet fiscal targets.
Borrowing since April came to £55 billion, compared with the £52 billion forecast by the Office for Budget Responsibility.
The government is under pressure to deliver more support for households facing the worst cost of living crisis in decades, while an impending economic downturn is expected to eat into tax revenues.
Public sector net borrowing was £4.9 billion in July, down by £800 million from the same month last year, but £5.9 more than July 2019 when the budget was in surplus.
The government usually runs a surplus in July because tax revenues are boosted by returns from self-employment, which are typically submitted twice a year in January and July.
Nadhim Zahawi, the chancellor, said: “I know that rising inflation is creating challenges for families and businesses, and it is also putting pressure on the public finances by pushing up the amount we spend on debt interest.
“To help people during this difficult time, government support is continuing to arrive in the weeks and months ahead, targeted to those who need it most like pensioners, people on low incomes, and those with disabilities. We are taking a balanced approach: safeguarding the public finances while providing significant help for households.”
Debt interest payments fell to £5.8 billion from a record £19.7 billion in June. Government bonds are indexed to the retail prices index, which hit 12.3 per cent last month, its highest level since March 1981. With inflation forecast even higher, the cost of servicing that debt will rise.
The public finances have come under sharp scrutiny in recent weeks after tax cuts became the main dividing line between the two candidates for prime minister.
Rishi Sunak believes that taxes should be maintained at their current level until inflation is brought down while Liz Truss plans to cut taxes immediately in an attempt to boost the economy.