The Italian was able to power into a seven-man move after a rapid start to the race in Classics country. The group swelled to nine riders, but a motivated peloton behind were not willing to give them much rope on a decisive stage for the general classification.
Viviani dug deep over the first pass of the famed Muur van Geraardsbergen climb, and pushed clear of his counterparts alongside Tony Martin (Katusha-Alpecin).
Shortly after Danny van Poppel also made a move of his own, attacking on the Bosberg and dragging a small group off the front of the peloton with him. Eventually the two team-mates were able to combine with 30km to go, but as the race blew apart behind on the second ascent of the Muur, it was left up to Viviani, who produced one more rousing attack.
Along with Ian Stannard the pair joined a sizable lead group that headed towards the finish in Geraardsbergen, with the GC favourites going toe to toe on the run in.
A late attack from Jasper Stuyven (Trek-Segafredo) saw him hold off the chasing pack by a single second at the line, while third place was enough to ensure Tom Dumoulin (Team Sunweb) wrapped up overall victory by 17 seconds.
Stage seven result:
1. Jasper Stuyven (Trek-Segafredo) 4:06:48
2. Philippe Gilbert (Quick-Step Floors) +1”
3. Tom Dumoulin (Team Sunweb) s.t.
4. Peter Sagan (Bora-Hansgrohe)
5. Tiesj Benoot (Lotto Soudal)
42. Elia Viviani (Team Sky) +2:03”
1. Tom Dumoulin (Team Sunweb) 24:34:33
2. Tim Wellens (Lotto Soudal) +17"
3. Jasper Stuyven (Trek-Segafredo) +46"
4. Greg van Avermaet (BMC Racing) +51"
5. Oliver Naesen (Ag2r-La Mondiale) +1:14"
59. Danny van Poppel (Team Sky) +23:59"