The Slovenian went down early in the stage but was back with the general classification contenders in time for the third of the day’s eight categorised climbs.
The LottoNL-Jumbo rider was dropped by GC rival Mikel Landa (Movistar) on the final climb, the 3km ascent of Alto Usartza, but Roglic limited the damage and secured victory by one minute and nine seconds.
Enric Mas: My first tour victory was complicated
Enric Mas (Quick-Step Floors) won Saturday's final stage, a 122.2-kilometre race from Eibar to Arrate, after surviving from the early breakaway and holding off Landa, who came home 12 seconds back.
Ion Izagirre (Bahrain-Merida) finished third on the stage to secure his third place in the GC standings, while Nairo Quintana moved up from eighth to fifth overall as he came home 30 seconds behind Mas.
Emanuel Buchmann (Bora-Hansgrohe) was a further 17 seconds back on the stage but just did enough to claim fourth overall, three seconds ahead of Quintana.
Enric Mas claims final stage glory on Tour of Basque Country
A final effort from Landa, along with his Movistar colleague Nairo Quintana could have put a lesser rider under pressure, but Roglic was confident enough in his lead, finish 42 seconds behind the Spaniard.
The victory for is the 28-year-old Slovenian's first professional win.
- 1 - Primoz Roglic (Slo) LottoNL-Jumbo, in 20-53-47
- 2 - Mikel Landa (Spa) Movistar Team, at 1m 9s
- 3 - Ion Izagirre (Spa) Bahrain-Merida, at 1m 42s
- 4 - Emanuel Buchmann (Ger) Bora-Hansgrohe, at 3m 14s
- 5 - Nairo Quintana (Col) Movistar Team, at 3m 17s
- 6 - Enric Mas (Spa) Quick-Step Floors, at 3m 29s
- 7 - Bauke Mollema (Ned) Trek-Segafredo, at 3m 50s
- 8 - Pello Bilbao (Spa) Astana Pro Team, at 4m 15s
- 9 - David De La Cruz (Spa) Team Sky, at 4m 15s
- 10 - Patrick Konrad (Aut) Bora-Hansgrohe, at 5m 30s