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 in 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.
Knowing Pinot is wary of fast downhills, they pushed hard down from the Col d'Izoard, at 2360m the highest point of this year's Tour. Bardet and Peraud, followed by Nibali and team-mate Jakob Fuglsang, went ahead. Valverde managed to bridge the gap, as well as Pinot, although he struggled.
"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.
"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 aid 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%, while Majka showed he was strongest in the breakaway group by going solo.
Nibali attacked the group of favourites at the 4km 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 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 threatened by Nibali, but held firm to cross the line with a 24-second advantage. It gave his Tinkoff-Saxo team something to cheer after they lost team-leader Alberto Contador last week when the Spaniard broke his shin 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.
Today's stage is a flat 222-km ride from Tallard to Nimes on roads open to crosswinds that could split the peloton.