Matteo Trentin edged out Peter Sagan in a photo-finish to win the seventh stage of the Tour de France in Nancy today.

The 234.5-kilometres route from Epernay was the second longest stage of this year's race and lit up when the riders reached the day's second and final categorised climb.

The summit of the Cote de Boufflers came with 5.5km to go, with Sagan (Cannondale) prominent over the top, but the leaders regrouped in the finale and Italian Trentin pipped Sagan by the narrowest of margins to claim Omega Pharma-QuickStep's first win of the 101st Tour.

The Belgian squad had to regroup following leader Mark Cavendish's exit on day one and Italian Trentin's second Tour stage win will come as a welcome success.

Tony Gallopin (Lotto-Belisol) was third as Vincenzo Nibali (Astana) retained the yellow jersey for another day by finishing 16th.

Saturday's lumpy, 161km eighth stage from Tomblaine to Gerardmer La Mauselaine provides a further test for the peloton, with the possibility a breakaway will prosper.

Ireland’s Nicolas Roche finished 40th today, 21 seconds off the pace, and now lies 49th overall + 15' 36'' behind leader Nibali.

A six-man breakaway formed after 9km, comprising Martin Elmiger (IAM Cycling), Alexandre Pichot (Europcar), Anthony Delaplace (Bretagne-Seche Environnement), Matthew Busche (Trek Factory Racing), Nicolas Edet (Cofidis) and Bartosz Huzarski (NetApp-Endura).

Sagan's Cannondale squad led the peloton, keeping the escapees on a tight leash.

FDJ, Movistar and Nibali's Astana team shared responsibility as another rider abandoned, with Belkin's Stef Clement crashing out after around 40km.

Danny van Poppel (Trek Factory Racing) then quit with a knee problem, with Orica-GreenEdge's Simon Yates, the 21-year-old from Bury, Lancashire, becoming the youngest rider remaining in the peloton.

The breakaway split with 40km remaining and Elmiger and Huzarski pressed on alone as the four others were caught.

Their lead was less than 30 seconds with 25km to go as Team Sky led the peloton on the undulating terrain.

Huzarski and Elmiger were caught on the slopes of the Cote de Maron, the day's first of two classified climbs in the final 20km.

The teams were frantically fighting for position and there was a crash in the bunch which brought down Tejay van Garderen (BMC) among others. The American was unable to recover and finished more than a minute down.

The frenetic pace continued towards the foot of the second and final climb, the 1.3km, category four Cote de Boufflers, the summit of which came 5.5km from the finish line.

Cannondale were again to the fore, working for Sagan, but Cyril Gautier (Europcar) was the first to initiate the attacks, with Tinkoff-Saxo's Nicolas Roche following and his leader Alberto Contador on his wheel.

Nibali was tucked in behind Contador, but Fabian Cancellara (Trek Factory Racing), one of the riders tipped for the stage, dropped out of contention.

Greg van Avermaet (BMC) crested the summit with Sagan on his wheel, but it took time for the Slovakian to convince the Belgian to work with him on the descent.

A technical finish, with two right-angled turns in the final 2km proved difficult.

Richie Porte (Team Sky) led a group of around 40 through the flamme rouge at 1km to go, sweeping up Sagan and Van Avermaet, with a crash splitting the leading group.

The main protagonists - Nibali, Contador and Porte among them - were safe and contended for the sprint.

Garmin-Sharp's Andrew Talansky tumbled in the closing 100m during the sprint, which Trentin won as Sagan missed out narrowly once more.

Sagan appears comfortable in the points classification's green jersey, but he is still chasing a fifth stage win of his career and a first of the 2014 Tour.