On the second hill-top finish of the race, Rabottini crossed the line in five hours 15 minutes 30 seconds, edging out Rodriguez on the final curve of the 169-kilometre leg from Busto Arsizio to the Piani dei Resinelli, a hill-top outside Lecco on Lake Como.
Hesjedal, a Victoria native who rides for Garmin-Barracuda, finished the stage in 12th, 39 seconds behind Rabottini. He slipped to second in the overall standings, 30 seconds behind Rodriguez.
It seemed as if Rodriguez had got the better of a tired Rabottini, who had led for more than 150 km, but the Italian used up his last reserves of energy to go past the Katusha cyclist for his second professional victory and his first stage win in a Grand Tour.
"Winning in this way gave me an incredible emotion," Rabottini said. "I came to the Giro with the hope of winning a stage. At the end I managed it. But it was so much work. It's the best day of my life.
"When I saw Rodriquez coming up at double speed, I even feared I wouldn't win. I had the strength to keep on going hard and at the end it worked. I dedicate this victory to my child who will be born in two weeks and obviously to my girlfriend."
Rabottini emerged unscathed from a crash on the last descent as the lashing rain made the roads slippy.
The Farnese Vini cyclist broke clear 18 km in, along with Guillaume Bonnafond, and the duo swiftly built an advantage of eight minutes.
Rabottini dropped Bonnafond about halfway through the stage as another breakaway group formed of Losada, Emanuele Sella, Amets Txurruka, Michal Golas, Marzio Bruseghin, Marco Pinotti, Diego Ulissi, Stefano Pirazzi, Evgueni Petrov, Adriano Malori and Matteo Carrara.
The chasing group was joined by 2004 Giro winner Damiano Cunego and Stage 14 winner Andrey Amador, but Rabottini had a gap of over five minutes on them and nine on the peloton.
His lead started to come down on the Category 2 Culmine di San Pietro — the penultimate climb of the day — and he lost more time when he skidded and crashed on a left-hand bend on slippy roads at the end of the descent, 17 km from the finish. But he was swiftly back on his bike.
Cunego, Amador, Losada, Pirazzi and Txurruka began to close down on Rabottini, but he still had a two-and-a-half minute lead at the start of the final climb, seven km from the finish.
However, led by Astana and Liquigas, the peloton started to up the pace at the foot of the the Category 2 Piani dei Resinelli, and quickly caught most of the chasing group.
Pre-race favourites Ivan Basso, Michele Scarponi and Rodriquez accelerated in the last mile and a formidable finish from the Spaniard saw him leave his two rivals behind. He appeared set to snatch victory from Rabottini before the 24-year-old sprinted home in the last few hundred yards.
Rodriguez finished 25 seconds ahead of two-time winner Basso and defending champion Scarponi. He now has a 30-second advantage over previous leader Hesjedal in the overall standings and will wear the pink jersey for a fifth day on Tuesday.
"Yesterday I suffered a lot but today I was able to take the the pink jersey again," Rodriguez said.
"It's clear that with the pink jersey on my shoulders our responsibility is growing, but we're going into the last week and there are mountains that suit me better then these. So I hope to fulfil my dream."
Basso is third in the overall standings, 1:22 behind Rodriguez.
"It was a very difficult stage, but I'm happy with my performance," Basso said. "I suffered a bit when Astana attacked, and to stay on their wheels I got to the foot of the last climbs with legs that felt like they were made of wood."
Another favourite, Frank Schleck, withdrew from the race 28 km into the stage. The Luxembourg rider has been nursing a right shoulder injury since crashing into Alex Rasmussen during stage 11 on Wednesday.
Jeremy Hunt, Graeme Brown and Giovanni Visconti also quit on Sunday.
Monday is a rest day after two days in the mountains. Tuesday's 16th stage is a mainly uphill 173-km trek from Limone sul Garda to Falzes/Pfalzen.
The Giro ends on May 27 in Milan.Suggest a correction