The final stage, which was 136 km long, comprised seven undulating circuits of Barcelona.
The two main protagonists broke away with about 28 km to go. The Belgian won the stage in a sprint and also claimed the King of the Mountains jersey by just a single point.
However, Roglič took the overall title by a mere 6 seconds after a week of intense racing.
It's his second stage race success in a row, having won the prestigious Tirreno-Adriatico race two weeks ago.