LOS MACHUCOS, Spain — Chris Froome lost some of his Spanish Vuelta lead in a brutal climb that challenged riders in a 17th stage won by Stefan Denifl of Austria on Wednesday.

Froome, coming off a comfortable time-trial victory on Tuesday, was struggling as he rode up the steep Los Machucos hill at the end of the 180.5-kilometer (112.1-mile) stage.

The Tour de France winner finished 14th and lost 42 seconds of his overall lead, which now stands at 1 minute, 16 seconds over Vincenzo Nibali of Italy. Wilco Kelderman of the Netherlands is third, more than two minutes behind Froome.

“It’s still a good position to be in,” said Froome, who is seeking his first Vuelta title. “I think we always knew today was going to be a though final and it certainly was. I am feeling good and we look forward to the next three days. Of course it’s never nice to lose time, but I still feel good. There’s just three days left and I hope we can get the job done.”

Three-time Vuelta winner Alberto Contador, who is retiring from cycling after this year’s Vuelta, thrived in the final climb to earn a second-place finish. He made up more than a minute on Froome, but remained fifth overall, more than three minutes from the lead with four stages left.

The route from Villadiego to Los Machucos was one of the most challenging in the three-week Vuelta. Riders had to deal with many steep climbs and fast descents through narrow roads, including the ruthless final hill which brought them to a near halt as they tried to manage slopes with a gradient of up to 26 percent.

Rain and mist during parts of the route made things even harder.

“I had super super legs today,” Denifl said. “I paced myself until today and I went all in. I just kept on pushing. The climb was perfect for me. Now I’ve won a stage at La Vuelta. It’s amazing. It’s the best day of my cycling life.”

Thursday’s 18th stage will take riders 169 kilometers (105 miles) from Suances to Santo Toribio de Liebana.

The Vuelta ends Sunday in Madrid.