Both men failed three times to clear 5.96 metres but the German had been faultless in moving up through the heights to notch 5.89 while Olympic champion Lavillenie, who had dominated the event all season, was uncharacteristically off form and had several failures along the way.
Olympic silver medallist Bjoern Otto of Germany took bronze on countback ahead of American Brad Walker and another German, Malte Mohr, after all three cleared 5.82. At 35 he becomes the oldest pole vault world championship medallist.
Holzdeppe had beaten Lavillenie at the Rome Diamond League this season but that was a rare blip for the Frenchman who came to Moscow with the six best vaults of the year under his belt.
Such was his confidence that after clearing 6.02m last month at the London Diamond League he attempted an audacious 6.16m world record attempt - 2cm beyond the 19-year-old mark of 6.14 set by Sergey Bubka, who was watching the action on Monday.
Maybe he was un-nerved by seeing his younger brother Valentin failing to clear his opening height and depart close to tears but Lavillenie was not his usual assured self at the Luzhniki Stadium.
He had the bar off at what for him should have been an easy 5.65 and, after passing at 5.75, missed his first attempt at 5.82.
Two more fails at 5.89 showed that something was wrong, though he then delivered an assured clearance, which he greeted with a guttural roar, on his third.
Holzdeppe, meanwhile, was calmly going about his business, clearing 5.65, 5.82 then the all-important 5.89 at the first attempt.
He too failed at 5.96 but when Lavillenie did the same, the gold was the German's.
"I had already beaten him this year and I knew that when you put him under pressure he is beatable," Holzdeppe said.
"So I cleared every height at the first attempt and had the advantage of going before him.
"When he had his last attempt I was really nervous - but we can start the party now."
Lavillenie, who took bronze at the last two world championships, had no complaints.
"My technique was bad - imagine I needed three attempts for 5.89," he said.
"I fought all the way and this is my third world championship medal but it is the hardest to take."