The 37-year-old former top-10 player, these day sporting peroxide blond hair, beat the Norwegian 6-4 7-5 6-7 (1-7) 6-3 on Wednesday.
He appeared to be on the brink of victory against a flat-looking Ruud when he led 5-2 30-0 in the third set with a double break but twice failed when serving for the match.
Fifth seed Daniil Medvedev came back from a set down to defeat Alexandre Muller. (AP PHOTO)
Ruud dominated the tie-break to extend the match but Fognini regained control in the fourth set and sealed victory with his fourth match point.
Fognini is now into the third round at Wimbledon for the seventh time in his 14th visit, although he has never gone further than that.
Back in 2019 his frustration on the grass was such he was fined $US 3,000 for suggesting Wimbledon 'should be bombed' in an on-court outburst.
"Maybe 14 is the lucky one," Fognini said. "I was 5-2 up and the match was almost done but then at 5-4 too many things were coming into my head.
"But this is why I love and hate this sport. In the end he's top 10 and I'm 37 and today was a good present for me."
Russian fifth seed Daniil Medvedev looked like being a shock departure when he fell a set down to defeat France's Alexandre Muller, but rallied to win 6-7 (3-7) 7-6 (7-4) 6-4 7-5.
Frances Tiafoe also progressed to the third round after defeating Croatian Borna Coric 7-6 (7-5) 6-1 6-3. The No. 29 seed now meets Carlos Alcaraz who defeated Australia's Aleksandar Vukic 7-6 (7-5) 6-2 6-2.