The Mitchelton-Scott rider began the final stage 10km time trial with a 25-second buffer over Roglic who is skilled in riding against the clock.
But Roglic (Jumbo-Visma) claimed victory in the overall standings by just one second.
“It was unbelievably close. I was lucky in the end,” Roglic said. I really pushed until the finish line. I was confident but I can only control myself.”
It was a disappointing end for Yates, who had been the overall leader since Mitchelton-Scott won the team time trial.
“It was a hard TT. I’ve done this TT many times and I always lose a chunk of time and it was close but it wasn’t enough,” Yates, the last man to ride the course, said.
“That’s how it goes, that’s bike racing.”
Jakob Fuglsang (Astana) finished third overall, 30 seconds behind Roglic.