Max Walscheid won stage three of the Tour de Yorkshire in Scarborough as Magnus Cort Nielsen retained the overall lead.
Team Sunweb's Walscheid won in a sprint finish after the peloton thwarted a late breakaway attempt by Frenchman Sylvain Chavanel of Direct-Energie with the finish line almost in sight.
Astana's Cort Nielsen, who took the overall lead with victory on the summit finish of the Cow and Calf on Friday, finished second to retain the leader's blue jersey.
Manxman Mark Cavendish of Team Dimension Data did not contest the sprint having been left in a group distanced late in the 181km stage from Richmond.
For the 24-year-old Walscheid, this was his biggest win since he was involved in a head-on collision with a car while training in 2016, and the German said he had chosen a great place to do it.
"The scenery is incredible and the Yorkshire fans, I think they are the best, there were massive crowds all over the road," he said. "It was a really nice parcours and to win a more difficult stage is good for me because normally I am more for the really flat bunch sprints.
"Now I am growing into a sprinter who can win more difficult stages."
Cort Nielsen's second place means the Dane leads the general classification by 10 seconds from Olympic champion Greg Van Avermaet going into Sunday's final stage.
Nielsen said he began the weekend eyeing this stage rather than Friday's, but was happy to emerge safe and sound and in the blue jersey after being caught in the huge crash which marred last year's finish into Scarborough.
"I knew today would be a good day and I thought it was maybe the day where I had the biggest chance," he said.
"I'm really happy with second, especially because last year I crashed in the sprint on this stage and broke a collarbone and a couple of ribs. It's really nice to get back in one piece and to have a result on this finish."