Greipel boxed Gaviria in next to the barrier on the left-hand side of the street, appearing to nudge him with his side.
"Dave will certainly get in both their ears and make them both think they can win it as a way of motivating them and as a way of playing this card as long as possible until there is a natural selection, a mountain stage or the Time Trail, or until there has to be a decision".
That meant that Sagan officially finished second, with John Degenkolb in third.
Chris Froome, meanwhile, stayed out of trouble, with the four-time Tour victor now sitting one minute and six seconds behind Van Avermaet in the standings.
The German, who won the Queen of the Classics in 2015, was one of three riders to jump away from the main pack 19km from the line and he was the fastest in the final sprint, beating overall race leader Greg van Avermaet of Belgium.
Froome recovered quickly to rejoin teammate Thomas but the Team Sky riders had fallen nearly seven minutes behind Van Avermaet and the breakaway group.
Despite having Sky teammates at the front of the peloton, once Froome got a wheel from teammate Jonathan Castroviejo, he was left all alone for several minutes until Wout Poels eventually dropped back to help him get back.
Sunday's Stage 9 will take riders over 15 cobbled paths scattered along 21.7 kilometers of the 156.5-kilometer course from Arras to Roubaix, near the Belgian border.
"Coming around that corner with three kilometres to go, we knew it was pretty sketchy".
Van Avermaet is not expected to be a threat in the mountains, and Froome suggested the Belgian "will find it hard to hang on tomorrow. Obviously Geraint is in the ideal place now, we should see him going in to yellow over the next couple of days", Briton Froome told reporters on Monday.
The good news for an ailing Martin - as well as the rest of the field - is they have just one more stage to complete before the event's first rest day. UAE Emirates leader Daniel Martin, the victor of Stage 6, bloodied his left elbow and tore the back of his shirt.