Ricciardo, who started from fourth on the grid, ran wide to avoid the upside-down Williams of Felipe Massa, which had been clipped by Kevin Magnussen’s McLaren, and just managed to squeeze his Red Bull Renault past the spark-spraying Williams as it careered across his path.
His evasive action cost him 11 positions, and he rejoined the race in 15th place.
But an inspired drive had him finish a very close sixth overall, to retain his number three position in the F1 Driver’s Championship, behind the dominant Mercedes pair of Nico Rosberg and Lewis Hamilton.
Rosberg won the race, becoming the first driver to win for Mercedes in Germany since Juan Manuel Fangio in 1954.
Second was Williams’ Valtteri Bottas, just ahead of Hamilton, with Sebastien Vettel fourth.
Ricciardo and Ferrari’s Fernando Alonso were hard to split for fifth place.
Ricciardo closed in on Alonso with eight laps to go, but the Spaniard, on fresher tyres, fought back. The pair traded places lap after lap in an enthralling warp-speed battle, with Alonso finishing just one-tenth of a second ahead of Ricciardo.