Poland's Rafal Majka took a big step towards winning the Tour de France polka dot jersey when he took a solo route to the stage victory as Italian Vincenzo Nibali strengthened his grip on the overall race.

Majka was the best climber on the 17th stage, a brutal 124.5-km trek from St Gaudens featuring four tough ascents, and extended his lead over Nibali and Spain's Joaquim Rodriguez in the mountain classification.

The win was his second stage victory after prevailing on the 14th stage in the Alps, and a third in four stages for Tinkoff-Saxo after leader Alberto Contador crashed out.

"I'm so happy because my team worked so hard for that result," said Majka, who has 149 points in the mountain classification. Nibali has 118 and Rodriguez 112 with 80 points left up for grabs.

Italian Giovanni Visconti was second with Nibali taking third place to extend his overall race lead to over five minutes.

"It was a nervous stage, I'm relieved," the calm Nibali said.

France's Jean-Christophe Peraud was fourth as he gained more than 50 seconds on compatriot Thibaut Pinot, who struggled in the final climb.

"In the third week, it's difficult every day, but I'm happy I can hold Nibali's wheel," said the 37-year-old Peraud.

Nibali leads Spain's Alejandro Valverde by 5:26 with Pinot in third place overall, six minutes off the pace. Peraud, who is expected to fare better in Saturday's time trial, lies fourth, eight seconds behind Pinot.

"I had a bad moment, but there were some team-mates to help me," said Valverde. "I found my rhythm again and managed to limit the damage."

The 24-year-old Pinot now has today's 18th stage to Hautacam to regain time on Peraud and Valverde.

"The ascent to Pla d'Adet did not really suit him, but he likes the climb to Hautacam," his FDJ.fr sports director Yvon Madiot said.