The West Australian rode in a group with his strongest rivals in the general classification through the first two category 1 climbs and most of the final ascent of the Col du Portet, before being distanced from the likely podium trio of Richard Carapaz (INEOS Grenadiers), Jonas Vingegaard (Jumbo-Visma) and Tadej Pogačar (UAE Team Emirates) as they surged away en route to the finish.
Pogačar held off late attacks from both challengers to take the stage and cap off a brilliant performance, while O'Connor dug deep in the final kilometres to pull away from his chase group and finish a minute and 26 seconds behind the yellow jersey holder, consolidating fifth overall and moving to within 17 seconds of fourth-placed Rigoberto Uran (EF Education Nippo).
Firmly back in form after experiencing his toughest day yet on the Mont Ventoux in stage 11, O'Connor was proud of his efforts to stay with the elite riders today in what was the hardest stage of this year's Tour.
“I felt really good today and I’m proud of how I performed," he said following the stage.
"I tried to go with Tadej and Vingegaard but it was too much for me so I played the second game and it was good to grab a couple of seconds at the end. I’m proud of today.
"I still showed that I deserve to be here. I think it's really great for the team too, because they've looked after me the whole week and put effort into it and now there's a genuine reward for it.
"It was pretty special to be fifth up there in a mountaintop finish at the Tour de France. It was a classic mountain stage today and it played pretty well for me. It wasn't crazy hot and it's beautiful up here. I'm just super proud to fight in the Tour de France with these big guys."
With Pogačar now almost six minutes clear at the top of the general classification after another stunning performance, O'Connor conceded the battle is essentially now for second place between the rest of the contenders as he previewed tomorrow's stage 18, the final stanza of the Pyrenees journey with a summit finish again awaiting the peloton on the Luz Ardiden.
"It'll be exactly the same as today," he said of the strategy for tomorrow's stage.
"I think we all try and do our best and see who’s the fastest up Luz Ardiden. I think it’ll be quite simple, it’s a short stage.
"To be honest, everyone knows Tadej is a level above so the rest of us are going to be looking at each other and trying to grab a few seconds when we can."
The Tour de France continues with Stage 18, another big day in the mountains, with the peloton summiting the dual hors categorie climbs of the Col du Tourmalet and the Luz Ardiden over a total stage distance of just 129.7 kilometres. Watch the racing action from 2130 AEST on SBS, SBS OnDemand and the SKODA Tour Tracker.