Roglic (LottoNL-Jumbo) completed the circuit around Lodosa in 22min 26sec, finishing nine seconds in front of New Zealand's Patrick Bevin (BMC) and 11 ahead of Team Sky's Vasil Kiryienka.
Roglic finally took the race lead after finishing second to Julian Alaphilippe (Quick-Step Floors) on the first two stages but Stage 4 was always going to be a playground for the powerful time trial specialist.
"I knew that all eyes were on me as a pursuer in the GC and as a time-trial specialist. That provided extra pressure," Roglic said.
"It was a flat time trial, but there was a lot of wind. At the finish, I saw that I had the fastest time, which made me very happy of course."
Roglic now leads Alaphilippe by 34 seconds on the general classification with Bauke Mollema (Trek-Segafredo) third at 1min 33sec.
Stage 5 hits the mountains with a 163km ride which includes two category two climbs before a category one ascent of the Azurki.
"We should not get ahead of ourselves," Roglic said. "At the beginning of the course I already said that I want to take it one day at a time. It’s not going to be easy, but I'm really looking forward to the last stages.”