The defending Tour de France champion, who is biding his time until the race hits the longer climbs of the Alps in the third week, trails Slovenian Roglic by 10 seconds after Stage 8.
"In the last two climbs the pace was really fast," Bernal said.
"It was not easy to stay with Roglič but I'm happy I stayed with the first group."
Bernal was briefly dropped several times when Roglič upped the pace in the final climb, a 9.7 km effort at an average gradient of 7.8%, to control fellow Slovenian Tadej Pogacar.
But every time he fought his way back, also with the help of Ineos teammate and Giro d'Italia champion Richard Carapaz, while Roglič had no support.
Jumbo Visma's Tom Dumoulin, the team's 'plan B', rode a hard pace to test the favourites, but the move backfired as he imploded and the Dutchman lost all hope of winning the race, leaving Roglic alone in the main contenders' group.
"When Dumoulin set the hard pace in the last climb I had the feeling I could not sustain it until the finale," Bernal said.
"I looked at the (power) numbers and I could not do this until the finale so I tried to manage myself. I tried to do what was best for me and I think I did a good job."
Bernal, who was suffering from back pains before the Tour, is expected to fare better in the Alps - where the longer climbs suit his abilities better.
The last Alpine stage also finished at 2,300 metres in Meribel, an altitude that could favour the Colombian.
But did Roglič miss a chance to put the hammer down?
"It was a hard tempo but like I said it's the first mountain stage and there is still a lot to come," Roglič said.
The Tour de France continues in the Pyrenees tomorrow, with another mountainous stage from Pau to Laurens set to test the peloton with steep climbs on the agenda. Watch the action from 8:05pm AEST on the SBS ŠKODA Tour Tracker and from 8:30pm on SBS and via SBS On Demand.