Alessandro Fedeli of Delko Marseille Provence took the stage win two seconds ahead of Bahrain-Merida's Jan Tratnik and Florian Kierner of Team Felbermayr-Simplon Wels.
Yates had been in the top 10 throughout the early part of the week but moved into the lead on Saturday with a dominant performance.
The Brit attacked five kilometres from the end of the stage, flying up the climb to Platak to gain a 10-second advantage, doubled by the bonus afforded to the stage winner.
It meant he came into the final day of the race holding a 15-second advantage over Villella and 17-second lead over CCC's Victor de la Parte of the CCC Team.
Yates remained in the peloton as none of his rivals joined the eight-rider breakaway, who one by one were picked off on the way through Zagreb except Fedeli.
The 23-year-old held off the big names of world tour teams trying to chase him down to claim a brilliant stage victory.
Yates clung on to his fast finish up the cobbles of the historic town to cross the line seventh, seven seconds ahead of Villella as the final stage failed to make any impact on the top three riders in the overall standings.