Germany’s annual rate of inflation has risen in May at a faster pace than in April, beating forecasts and posting the highest reading since December 1973, according to preliminary data released by German statistics office Destatis on Monday.

Consumer prices rose 7.9% on year measured by national standards, against the 7.5% forecast by economists in a Wall Street Journal poll. They rose 8.7% on year by European Union harmonized standards, above economists’ forecast of 8.1%.

A similarly high inflation rate in Germany was last recorded in the winter of 1973, when mineral oil prices increased as a result of the first oil crisis, the statistics office said.

Since Russia’s attack on Ukraine, energy prices have markedly increased and have had a considerable impact on the high rate of inflation, Destatis said. Energy prices rose 38.3% in May year-on-year.

Food prices also increased above average, posting a 11.1% on-year increase, Destatis said.

Other factors pushing inflation higher are supply-chain problems due to the pandemic and significant price increases as the economic recovery got under way, Destatis said.

Consumer prices rose 0.9% on month by national standards and 1.1% by EU-harmonized standards. Economists polled by the Wall Street Journal had expected prices to rise 0.5% on month by national standards and 0.4% by EU-harmonized standards.

Final results will be released on June 14.

Write to Maria Martinez at maria.martinez@wsj.com