Astana rider Nibali finished the 14th stage, a 177-km mountain trek from Grenoble, in second place but beat Alejandro Valverde by one minute as the battle for second overall looks set to go to the wire.
Valverde trails Nibali by 4:37 overall with Romain Bardet in third place 13 seconds further back after he, fellow Frenchman Thibaut Pinot and American Tejay van Garderen dropped Valverde over the closing kilometres of the final climb to the ski resort of Risoul.
Pinot is fourth overall 5:06 off the pace, 43 seconds ahead of Van Garderen while another Frenchman, Jean-Christophe Peraud, is sixth (6:08) after taking third place in the stage.
"The plan was to control the race, so when there was an attack on the descent I followed," said Nibali, who is looking to become the sixth man to win all three grand tours after victory on the Vuelta in 2010 and last year's Giro.
Bardet's AG2R-La Mondiale, whose ambition is to win the team classification and the white jersey for the best Under-25 rider, tried several coups on a nervous day.
Knowing that Pinot is cautious of speedy downhills, they pushed hard in the descent from the Col d'Izoard, at 2,360 metres the highest point of this year's Tour.
Bardet and Peraud, followed by Nibali and his team mate Jakob Fuglsang, went ahead. Valverde managed to bridge the gap, as well as Pinot although he struggled a lot.
NIBALI'S ATTACK
"We did not just do it for Pinot, we did it for all the overall contenders. I told my team to set a high pace on the descent because it's the way of racing that I like," said Bardet.
"I'm clearly happy because I gained time on Valverde.
"It's a good sign that they're attacking me on the descents," said Pinot.
"They can't do it on the climbs, so they're targeting my weakness."
Van Garderen was dropped but eventually made it back into the yellow jersey group with the help of his BMC team mates.
AG2R set a high pace from the start of the final climb, a 12.6-km ascent at 6.9 per cent, while Majka showed he was the strongest in the breakaway group by going solo.
Nibali attacked the group of favourites at the 4-km banner and only Peraud could follow his wheel.
Behind, Valverde struggled and could not sustain the pace set by Pinot and Van Garderen in the chasing group.
Valverde explained that he suffered a mechanical problem. "Pinot touched my wheel and it broke my derailleur gear so I could not change gears in the last kilometres," the Spaniard said.
Majka was under threat by Nibali but he held firm to cross the line with a 24-second advantage.
It gave his Tinkoff-Saxo team something to cheer about after they lost team leader Alberto Contador last week when the Spaniard broke his shinbone crashing on a descent.
"We lost Alberto after putting a lot of effort into this Tour, so we needed to win," team owner Oleg Tinkoff said in tears.
Monday's 15th stage is a flat 222-km ride from Tallard to Nimes on roads usually open to crosswinds that could split the peloton.