The CPI figures came in above expectations of 9.8%, and up from 9.4% in June.
The Office for National Statistics said that rising food prices made the largest upward contribution to the change in prices from June, with the greatest movements coming from bread and cereals and milk, cheese and eggs.
Food prices, along with transport and housing, make up the bulk of price rises in the last year, with fuel prices up by 43.7% in the year to July, the highest rate ever recorded.
Meanwhile core CPI, which excludes energy, food, alcohol and tobacco, sat at just 6.2%, highlighting where the bulk of price rises originate from.
The announcement makes the UK the third developed country to reach double digits inflation in July, joining Spain and the Netherlands. The USA announced last week that its inflation rate had plateaued between June and July, sitting at 8.5% annually.
Luke Bartholomew, senior economist at abrdn, said: “UK inflation continues to surge higher, coming in stronger than forecast once again, increasing the risk that it will ultimately peak even higher than the 13% figure forecast by the Bank of England.
“Every upwards inflation surprise tightens the bind the BoE finds itself in, with mounting inflation pressure combined with growing recessionary headwinds. Given the strength of underlying inflation pressure we continue to expect the Bank to deliver another 0.5% interest rate increase at its next meeting.
“With monetary policy having to tighten even in the face of bad economic news, investors continue to have little in the way of a safety net from central banks, which is likely to keep markets volatile.”