The Italian had an excellent lead out from his Team Sky teammates going into the final corner at 300 metres to go but he knew that Cavendish was on his wheel. He produced a gradual effort, winding up the speed and tried to close Cavendish's trajectory by drifting towards the barriers but the Manxman also cleverly used his sprinting skills to slingshot off Viviani's wheel and win on the line.
Cavendish cracked a smile as he hit the line, while Viviani was dissapointed to be beaten. Especially by Cavendish, his rival in the sprints and on the track in the Omnium.
"I can only accept defeat and try to get revenge on Sunday on the final stage," Viviani said after the finish.
"I think we did a really good job today. Yesterday we did a lot of work during the stage but we didn't finish it off. Today we did a perfect job and so the lead-out train was fantastic. Danny van Poppel pulled for two kilometres and lined out the peloton. Then Andy Fenn and Owain Doull put me in the best possible position going into the last corner.
"Unfortunately Cavendish is back as the best sprinter in the world and it's always dangerous when he's on your wheel. I was hoping he'd be a bit further back but after the corner I saw that was with me and I knew he'd be on my wheel. I tried to produce a progressive sprint all the way to the line and in fact he only came past me right on the line. I can only congratulate him."
Like Cavendish, Viviani has had a long 2016 season, mixing road racing at WorldTour level with track racing and training for the Omnium at the World Championships in March, and again for the Olympics in Rio in August. He could have kicked back and celebrated his gold-medal performance in Rio but instead he kept training and targeted the UCI Road World Championships in Qatar. Illness in September hit his form and a cramp stopped him contesting the sprint as he would have liked but he agreed to continue racing after his disappointment and travelled to Abu Dhabi.
"I think it's only right to race until the very end of the season and payback Team Sky for their support," he explained.
"They let me prepare for the Omnium and so part of my gold medal is theirs. It's never easy being the leader at Team Sky but I know that I've got to take every opportunity I have to win. Especially here because I've got a great lead-out train. They gave me a great lead out today but there's little you can do against a rider like Cavendish in a sprint like that."
Viviani was angry after the Omnium at the World Championships on the track, after he surged past him in the final sprint of the points race, stopping him winning the world title. However, he revealed the two have since cleared the air and rebuilt their relationship based on reciprocal respect for their sprinting talents.
Cavendish described Viviani as best Omnium rider in the world before the start of the Abu Dhabi Tour and Viviani sportingly repaid the compliment, even in defeat.
"We've always respected each other in races. We had a problem at the world track championships in London but we cleared things up," he explained.
"I've always believed you should try to have a good relationship with every one, also because it can come in handy in races. Cycling is already hard enough, so falling out with people only makes it harder."