Spaniard Joaquim Rodriguez retained the overall leader's pink jersey after the 258km stage, the longest in this year's race, in which Italy's Francesco Chicchi was second just ahead of Lithuanian Tomas Vaitkus.
Britain's world champion Mark Cavendish finished fourth despite the Sky rider being well placed to challenge in third just 400m from the line when several riders fell coming out of the final bend.
But the Brit could not match the final sprint of 29-year-old Ferrari, the rider who was responsible for Cavendish's fall during the third stage, and who achieved the biggest win of his career.
In a marathon stage lasting just under seven hours a group of five riders - Oliver Kaisen, Mickael Delage, Manuele Boaro, Stefan Denifl and Adrien Saez - broke away from the 10km mark and which lasted until the final kilometres.
Thursday's 12th stage covers 155km from Seravezza to Sestri Levante and includes one category two and two category three climbs, with the final just 11km from the finish line on the Ligurian coast in north western Italy.
Stage
1. Roberto Ferrari (ITA/AND) 6hr 49min 05sec, 2. Francesco Chicchi (ITA/OPQ) same time, 3. Tomas Vaitkus (LTU/GEC) s.t., 4. Mark Cavendish (GBR/SKY) s.t., 5. Manuel Belletti (ITA/ALM) s.t., 6. Giacomo Nizzolo (ITA/RSH) s.t., 7. Daniel Schorn (AUT/APP) s.t., 8. Arnaud Demare (FRA/FDJ) s.t., 9. Danilo Wyss (SUI/BMC) s.t., 10. Geoffrey Soupe (FRA/FDJ) s.t.
Selected
16. Mark Renshaw (AUS/RAB) s.t, 36. Damiano Cunego (ITA/LAM) s.t., 42. Paolo Tiralongo (ITA/AST) s.t., 71. Ivan Basso (ITA/LIQ) s.t., 95. Frank Schleck (LUX/RSH) s.t., 158. Taylor Phinney (USA/BMC) at 10min 02sec
Overall
1. Joaquin Rodriguez (ESP/KAT) 47hr 16min 39sec, 2. Ryder Hesjedal (CAN/GRM) at 17sec, 3. Paolo Tiralongo (ITA/AST) 32, 4. Roman Kreuziger (CZE/AST) 52, 5. Benat Intxausti (ESP/MOV) 52, 6. Ivan Basso (ITA/LIQ) 57, 7. Damiano Caruso (ITA/LIQ) 1min 02sec, 8. Dario Cataldo (ITA/OPQ) 1:03, 9. Eros Capecchi (ITA/LIQ) 1:09, 10. Rigoberto Uran (COL/SKY) 1:10.