After a kilometer of steady climbing, the Movistar rider edged across the line over a bike length ahead of stage two winner Petacchi. Italian Roberto Ferrari took third.

Dutchman Pieter Weening remained the overall leader for a second day while favorite Alberto Contador sits ninth, 30 seconds back.

"I had this stage marked down with a cross in my route book because I knew the uphill would favor me," the 29-year-old Ventoso, whose last Grand Tour victory came on stage three of the 2006 Tour of Spain, told reporters. "But I thought that Petacchi was going to get it." "I'd followed his wheel all the way up the climb, but then he managed to distance me." "Finally, though, he cracked with about 20 meters to go, slowed down and I could get past him. It was very close." Ventoso said that he had exploited his rivals' hard work in order to get in an ideal position to claim the 27th victory of his career.

"My thanks to Danilo Hondo for doing an incredible job of keeping the opposition under control on a big climb before the finish.

"Then Danilo Di Luca lined the bunch out which made it a lot easier.

"After that, I knew I had a good chance." An exhausted Petacchi, slumped against the barriers, said he ran out of gas.

"There was nothing I could do," he said.

"With about 40 meters to go, my legs blocked. I stopped pedaling because I knew Ventoso was going to win anyway." Race leader Weening, who holds a slim two-second lead over Kanstantsin Sivtsov of Belarus, was upbeat about his chances on Friday's first summit finish of the race, but said he did not think he could win the Giro.

"I don't think I can win outright, I've been trying for the overall for a while now in stage races and it's never worked." The Giro finishes on May 29.