MONTEVERGINE , Italy — Richard Carapaz pulled off a superb final attack to win the eighth stage of the Giro d'Italia on Saturday, and British rider Simon Yates remained in the overall lead after the second mountain finish.

Carapaz stormed the end of the final climb to pass Koen Bouwman, who led for most of the day. The Movistar cyclist claimed his first win in a Grand Tour, and the first for Ecuador.

Davide Formolo led the peloton over the line to finish second, seven seconds behind. Thibaut Pinot was third and Ottawa's Michael Woods was the top Canadian in ninth.

"I worked a lot before the Giro," Carapaz said. "Having the first Grand Tour win, it's emotional.

"I had good legs, so I decided to attack from far out, two kilometres to go. I decided it was the right time to go alone, because I knew I couldn't win in a sprint."

There was an early break of eight cyclists, and Mads Pedersen was dropped before the halfway stage.

The gap to the remaining seven hovered around the five-minute mark before the peloton began to reel them in.

Their advantage stood at just over two minutes as they started up the 15-kilometre climb to the finish, with the rain lashing down, and they were eventually caught.

Bouwman, who attacked from the breakaway early in the climb, was the last to be swept up as Carapaz passed him in the final kilometre.

The general classification was unchanged and Yates, who won the young rider classification at last year's Tour de France, retained his 16-second advantage over defending champion Tom Dumoulin.

"We wanted to be in front for the climb," Yates said. "We knew because of the rain in the final, the hairpins would be very slippery. We wanted to take them in the front. We rode an even tempo. It was a very hard start, so maybe the breakaway didn't have good enough legs to stay away.

"Maybe I would have liked to take some bonus seconds in the final, but I got a little boxed in and I couldn't get out to sprint. It's one of those things."

Four-time Tour de France winner Chris Froome also finished in the main group despite being involved in another crash which left him with a bloody elbow. He remained 1 minute, 10 seconds behind, but slipped to ninth place.

Woods was 12th overall, 1:33 off the lead.

Sunday's ninth stage has another mountain finish, at the end of a 225-kilometre (140-mile) route from Pesco Sannita up to Gran Sasso d'Italia.

The Giro ends in Rome on May 27.