Frenchman Nacer Bouhanni claimed his second stage win of the Giro d'Italia but Michael Matthews held on to the leader's pink jersey.
The 23-year-old FDJ rider secured his first Grand Tour victory on Tuesday and proved that was no fluke when he edged the run-in to Foligno.
Australian Matthews, 23, also contested the sprint but trailed in fourth.
"I started the sprint well," Bouhanni said. "And I just managed to get in front at the end."
Bouhanni's win on Friday was impressive for his guile in staying out of trouble on the town's tight roads before he beat Trek's Italian Giacomo Nizzolo into second by half a wheel.
As the victories mount, Bouhanni faces inevitable comparison with leading sprinters such as Britain's Mark Cavendish and the German Marcel Kittel.
"Kittel and Cavendish are great sprinters," he added. "I'm only 23, and my goal is always to improve, not just from season to season, but every time I go out training.
"I try to learn from my mistakes, and I try never to make the same one twice. But I don't think I can be compared with Kittel and Cavendish. Their careers are very different from mine."
A five-man breakaway held a five-minute gap at the summit of the fourth-category Valico della Somma with 40km to go.
The peloton began the chase and, for the first time since the race began in Belfast last week, were able to enjoy dry roads on the last sprinters' stage until Tuesday.
The advantage was pegged back to just three minutes within 15km and the break was finally swallowed up inside the final three kilometres.
Bouhanni, who became the first Frenchman in three years to win a Giro stage when he triumphed in Bari, added: "The climbs towards the end today were not easy, but the team did a great job for me in the last 50km."
Orica GreenEdge sprinter Matthews maintained his 21-second overall lead after adapting his race to take account of the tight, technical finish.
"It was a bit more difficult than it looked on paper," he said. "It was more technical than we had thought which meant we had to be on the front of the bunch.
"The team got me to the right position, but I did not quite have the legs for the sprint in the end."
Saturday's 179km eighth stage sees the race hit the high mountains for the first time as it takes in the category one Cippo di Carpegna climb with 40km to ride then finishes on the summit of the iconic Montecopiolo.
1. Nacer Bouhanni (Fr/FDJ) 5hrs 16mins 5secs"
2. Giacomo Nizzolo (Itl/Trek) ST
3. Luka Mezgec (Slo/Giant) ST
4. Michael Matthews (Aus/Orica) ST
5. Roberto Ferrari (Itl/Lampre) ST
6. Tyler Farrar (USA/Garmin) ST
7. Enrico Battaglin (Itl/Bardiani Valvole) ST
8. Boy van Poppel (Ndl/Trek) ST
9. Ivan Rovnyi (Russia/Tinkoff) ST
10. Elia Viviani (Itl/Cannondale) ST
1. Michael Matthews (Aus/Orica) 29hrs 34mins 19secs
2. Cadel Evans (Aus/BMC) +21secs
3. Rigoberto Uran (Col/ Omega) +1min 18secs
4. Rafal Majka (Pol/Tinkoff) +1min 25secs
5. Steve Morabito (Sui/BMC) ST
6. Matteo Rabottini (Itl/Neri Sottoli) ST
7. Ivan Santaromita (Itl/Orica) +1min 47secs
8. Fabio Aru (Itl/Astana) +1min 51secs
9. Tim Wellens (Belgium Lotto) +1min 52secs
10. Ivan Basso (Italy/Cannondale) +2mins 6secs