Greg Van Avermaet (BMC Racing) won from an escape and took the race lead. Sky, meanwhile, worked at the front of the peloton to keep Chris Froome safe, with the Brit arriving with a small group 33 seconds ahead of Contador and 8-38 minutes ahead of Nibali.
In the general classification, Froome sits in a favourites group at 5-17, a lead of 1-21 over two-time winner Contador.
"It was a good day for us," Froome said after cooling down at the team bus. "We stayed up front and we stayed out of trouble. We took it on from the start.
"It was more about keeping the GC intact and staying out of trouble. I wasn't really hoping to get time on my main rivals, given it was a tricky finish, it wasn't a massive GC day. I was hoping not to lose time to my main rivals.
"I am pretty happy it how it turned out. I was happy to have support right to the end, and it showed the strength of the team."
Team Sky boss Sir Dave Brailsford said on Tuesday that his team would not ride to put Contador in trouble as he is suffering from his injuries. On stage five they set a pace with Luke Rowe and Ian Stannard through the mid-mountain stage, which comes early in the 2016 Tour.
Watch highlights of stage five of the Tour de France
"I was surprised by Vincenzo, yes. I would've expected him to come here with his A Game," Froome added.
"To be honest, with Alberto that's quite normal with a couple of the big crashes he had. No one wants to see that, us included. I'd rather gain time on him in the mountains, not because he's hurt and injured."
Tinkoff said that they would have sent its men to the front for Contador had Sky not been there.
"I don't' know why Sky rode for so long, to be honest," Tinkoff sports director Sean Yates said.
"They were riding from kilometre 50. Maybe they had intentions of going for the stage, but when the break split, they really put the hammer down. Then other teams took it up, Movistar and Romain Bardet attacked. But, if they [Sky] wanted to distance Alberto they would've attacked full gas on the penultimate climb."
"It was to take control and to just stop any big attacks really," Geraint Thomas explained of Sky's drive.
"Movistar did all the damage and for us, it was about controlling the pace. The last thing you want is for nobody to ride and to have attacks all over the place. ‘Frostie’ [Mikel Nieve] just set a decent tempo and no one went until the end."
The early climbing stage shifted the Tour in favour of Froome and a handful of favourites, including Nairo Quintana (Movistar), Fabio Aru (Astana), Romain Bardet (AG2R La Mondiale), Tejay van Garderen (BMC Racing) and Pierre Rolland (Cannondale). After one sprint stage on Thursday, the contenders will further be tested in the Pyrénées on Friday.
"It's just a handful of seconds here and there, you can't write Contador off yet. Just look at all the stage races he's won," Thomas added. "It's a bonus [what happened today], but we certainly aren't taking anything for granted."
Thank you for reading 20 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1