Italian Diego Ulissi delighted home fans by winning a dramatic stage eight of the Giro d'Italia but Australian Cadel Evans' fifth place meant he claimed the overall lead.
Ulissi edged out Croatia's Robert Kiserlovski in the closing moments of the 174km leg from Foligno to Montecopiolo incorporating the category one climb of the Montecopiolo to record his second stage win.
Julian Arredondo, who was in an early breakaway, had a chance to solo to victory but was caught by Frenchman Pierre Rolland in the final moments, only for the Frenchman in turn to be passed in the last 300 metres.
Evans, 2011 Tour de France champion, came home fifth to claim the pink jersey and lead the overall standings by 57.3 seconds from Colombian Rigoberto Uran with Poland's Rafal Majka just over ten seconds further behind.
Italian Michele Scarponi lost lots of time after struggling all day with a leg injury.
"I hung in there all day to stay in the leading group. Then I did a super sprint," Ulissi told Italian media.
Sunday's 172km ninth stage is from Lugo to Testola.
Ireland's Nicolas Roche finished 35th, while compatriot Philip Deignan came home 78th. Roche is now 49th in the overall classification, with Deignan 91st.