The 28-year-old Slovenian broke away on the last climb up Volovjek, retaining a comfortable advantage ahead of the riders in pursuit descending into Kamnik.
This enabled Roglič (LottoNL-Jumbo) to take the yellow jersey off Columbian Rigoberto Uran (Drapac Cannondale), who finished fifth today.
The position augurs well for Roglič ahead of Sunday's 21.5 km time trial between Trebnje and Novo Mesto where he is considered a favourite.
Roglič took silver in the individual time trial at last year's World Cycling Championships. He also became the first Slovenian to win a Tour de France stage.
Slovenia's Matej Mohorič crossed the finish line of stage four as the first in the front group in pursuit. who finished the race 32-seconds behind Roglič.
Coming in third today was Pole Rafal Majka, last year's winner of the Tour of Slovenia, followed by Slovenia's Tadej Pogačar.