Alessandro Petacchi (Omega Pharma QuickStep) and Gerald Ciolek (MTN-Qhubeka) finished second and third respectively.
An early breakaway group of five riders built up a lead of five minutes before the blustery conditions took their toll and the peloton began to reel them in.
With the gap down to under a minute and 43 kilometres left to ride, Sojasun's Anthony Delaplace broke clear from the chasing pack and quickly overhauled the group ahead before taking the lead outright.
But, despite building a healthy lead, his bid for solo success ended 14 kilometres from the finish as Sky dragged the peloton back into contention.
The riders jostled for position in the final stages, which led to a huge pile-up with 200m remaining, as Viviani’s late surge proved decisive.