The 24-year-old Spaniard Sanchez, who had defeated Frenchman Alaphilippe in the steep finish at Rapolano Terme, shook his head in shock.
Luke Plapp, a rider for Jayco Alula, who was in the third group to break away, weakened a little bit close to the finish line but managed to secure the last podium spot.
For the sixth day in a row, two-time Tour de France winner Tadej Pogacar held the lead in the overall standings, 46 seconds ahead of Geraint Thomas of Britain.
On the stage, which comprised parts of the white gravel roads of Tuscany used in the one-day Strade Bianchi event, Pelayo claimed he had bided his time.
This is incredible. I’m at a loss for words,” he remarked.
“I anticipated that today would be quite difficult—a full day of work. I made an effort to conserve energy and bide my time. Everyone started attacking after two hours of racing, so I moved.