Degenkolb (Trek-Segafredo) completed the 156.5km stage in 3:24:26, beating Van Avermaet (BMC Racing) and Lampaert (Quick-Step Floors) on the line.
Van Avermaet retained the race lead. The tenth stage will take place on Tuesday.
One of the pre-race favourites, Richie Porte of BMC Racing, crashed several kilometres into the ninth stage and was forced to abandon the Tour because of a collarbone injury.
Today’s stage included 15 cobbled sectors, 12 of which had been part of this year’s Paris-Roubaix event. The first one came at the 47.5km mark.
During the early stages of the stage a five-man breakaway ‒ Thomas de Gendt, Antwan Tolhoek, Jerome Cousin, Damien Gaudin and Omar Fraile ‒ opened a 34-second lead.
Reinardt Janse van Rensburg, Chad Haga, Olivier le Gac and Nicolas Edet, were trying to bridge the gap at that point.
The “escapees” went two minutes ahead of the peloton and 34 seconds ahead of the chasers before the two groups merged as a 10-man breakaway.
Team Bora-Hansgrohe controlled the break over the cobbled sectors as the group opened a three-and-a-half-minute lead over the peloton by sector 14.
The winner of previous two stages, Dylan Groenwegen, crashed on the cobbles with just over 80km remaining and fell behind the peloton.
With 50km remaining, Gianni Moscon set the pace in the peloton and the gap dwindled to one-and-a-half minutes.
Several kilometres later Janse van Rensberg attacked and got away, as Gaudin chased after him. The breakaway had only 35 seconds over the peloton at the time.
Janse van Rensburg and Gaudin led the race for approximately 30km before being swallowed with about 15km remaining.
Lampaert, Degenkolb and Van Avermaet broke away shortly after and created a 36-second lead with 10km remaining.
With 3km left, they extended their lead to almost a minute as a series of attacks ensued from within the peloton and chasing groups.
Peter Sagan led the chase in the final two kilometres, as the trio’s lead reduced slightly.
In the final sprint, Degenkolb came out on top, beating Van Avermaet into second, with Lampaert following closely in third. It was Degenkolb’s first stage win in the French Grand Tour.
Philippe Gilbert won the chase, finishing fourth 19 seconds back, with Sagan getting home in fifth.
“I was chasing the victory for so long. It’s really hard to describe – pure happiness, really,” an emotional Degenkolb said afterwards.
“It was a really hard fight all day. It is also a victory for the team. We really had a plan to stay out of trouble all the time, and it worked out really well. It was unbelievable.
“This is a very big victory. I have been through a lot of things and I’ve had such a hard time. I’m so happy to dedicate this victory to one of my best friends, who passed away last winter.
“This was really something for him,” he added.