It was Cavendish’s first victory in the 2013 Tour after getting boxed in at the climax of the opening stage before failing in a solo bid to take stage two.
Steele Van Hoff placed third but was lucky to avoid a crash after clipping stage one winner Viviani’s rear wheel close to the finish.
A group of eleven riders broke away from the peloton early in the stage as it travelled from Stoke-on-Trent but the gap was bridged with a kilometre to go to set up a sprint to the line.
Sky’s Bradley Wiggins retained the leader’s gold jersey after his dominant time-trial on Wednesday.
Thursday’s stage winds south through Wales from Machylleth to Caerphilly with two ascents of Caerphilly Mountain set to shake-up the overall standings.
Stage Four Results
1 Mark Cavendish (GB) Omega Pharma-Quick Step 4:45:42
2 Elia Viviani (Ita) Cannondale Pro Cycling
3 Steele Von Hoff (Aus) Garmin-Sharp
4 Matteo Pelucchi (Ita) IAM Cycling
5 Jose Joaquin Rojas Gil (Spa) Movistar Team
1 Bradley Wiggins (GBr) Sky Procycling 16:11:36
2 Ian Stannard (GBr) Sky Procycling 0:00:37
3 Martin Elmiger (Swi) IAM Cycling 0:00:47
4 Jack Bauer (NZl) Garmin-Sharp 0:00:55
5 Alex Dowsett (GBr) Movistar Team 0:00:57