The Liquigas rider prevailed in a bunch sprint at the end of the flat 117km stage from Tiananmen Square to the Bird’s Nest Olympic Stadium.
The Italian beat Britain's Andy Fenn of Omega Pharma-Quick-Step and Norway’s Edvald Boasson Hagen, the World road race silver medallist from Team Sky, to the line to take the overall leader's jersey.
Marco Bandiera (Omega Pharma - Quick-Step), Matthieu Ladagnous (FDJ), Adriano Malori (Lampre), Bert-Jan Lindeman (Vacansoleil-DCM) and Craig Lewis (CSS) escaped early and built up a lead of 2:40 after 15km.
But the stage concluded with 12 laps of a 7.8km circuit and Orica-GreenEDGE, Liquigas and Rabobank did most of the work to reduce the deficit for their sprinters.
The quintet were caught on the penultimate lap to set up the gallop to the line where Viviani rewarded the work of his team by powering down the inside to win by a bike's length.
All 18 WorldTour teams and the Chinese national team line up in the second edition of the five-day race with one or more climbs on the route in the remaining stages.