Orica-Scott rider Yates, 24, started Sunday second overall but climbed off with 75km of the 210km stage remaining.
Slovak Sagan won an uphill sprint to take his second victory of the race, ahead of France's Thibaut Pinot, who also moved second overall behind leader Nairo Quintana of Colombia.
Geraint Thomas was fourth on the stage.
The British Team Sky rider is now up to sixth overall, with two stages remaining.
Overall standings after stage five:
1. Nairo Quintana (Col/Movistar) 21hrs 34mins 51secs
2. Thibaut Pinot (Fra/FDJ) +50secs
3. Rohan Dennis (Aus/BMC) +1min 06secs
4. Primoz Roglic (Slo/LottoNL) +1min 15secs
5. Tom Dumoulin (Ned/Sunweb) +1min 19secs
6. Geraint Thomas (GB/Team Sky) +1min 23secs
7. Rigoberto Urán (Col/Cannondale-Drapac) +1min 30secs
8. Jonathan Castroviejo (Spa/Movistar) +1min 32secs
9. Bauke Mollema (Ned/Trek-Segafredo) +1min 37secs
10. Simon Spilak (Slo/Katusha-Alpecin) +1min 59secs
World champion Peter Sagan won stage five of Tirreno-Adriatico in Italy as Britain's Adam Yates abandoned the race because of illness.