Geraint Thomas withdrew from the Giro d'Italia with a fractured pelvis before Arnaud Demare edged out Peter Sagan and Davide Ballerini to win stage four on the sea front in Villafranca Tirrena.

On a day when Joao Almeida padded his lead in the pink jersey, the big news came before the 140 kilometre stage left Catania, with Thomas not taking the start a day after the pre-race favourite hit the deck hard when he rode over a stray water bottle at the start of Monday's stage to Mount Etna in a freak incident.

The 34-year-old finished the stage more than 12 minutes down before being sent for X-rays. Although those initially showed no broken bones, fresh scans on Tuesday revealed a "small undisplaced fracture in the lower part of the pelvis.

Thomas' crash was part of a dramatic shake-up of the general classification on Sicily's volcano, but a day later the focus shifted to the sprinters given the long downhill approach to the finish line.

Sagan's Bora-Hansgrohe team worked hard on the one major climb of the day, the Portella Mandrazzi, to distance some of his sprint rivals, and though Elia Viviani got back in, Fernando Gaviria had to give up the chase.

But for all Bora's hard work on the climb, they lost their position on the final corner as they reached the sea front. As Demare's Groupama-FDJ team-mate Miles Scotson's late charge came to nought, Sagan launched an early sprint but could not hold off Demare as it went to a photo finish.

A shot of the riders on Stage 4

It means another second place for Giro debutant Sagan after he finished runner-up to Diego Ulissi on Sunday, an all too familiar feeling for a rider who now has 30 second-place finishes in Grand Tours to go with his 16 stage victories.

Almeida used the intermediate sprint 25km from home to pad his slender lead in the pink jersey, picking up two bonus points on Monday's stage winner Jonathan Caicedo, who had begun the day on the same time.

There was otherwise little change at the top. Wilco Kelderman is fourth, 44 seconds down, while two-time Giro winner Vincenzo Nibali remains sixth at 57 seconds, with Jakob Fuglsang and Steven Kruijswijk ninth and 10th respectively.

After Simon Yates' struggles on Mount Etna and Thomas' withdrawal, Almeida's Deceuninck-QuickStep team-mate James Knox is 16th, one minute 42 seconds down.