Cannondale's Ratto led from start to finish on the 155.7km ride from Baga to Andorra as he was part of an early five-man breakaway group and then took to the front on his own with over 40km to go to finish ahead of Astana's Nibali and Christopher Horner.
RadioShack's Horner and Nibali were the big winners in the overall race standings, though, as the American moved ahead of Ireland's Nicholas Roche and Spaniard Alejandro Valverde into second place, while Giro d'Italia winner Nibali extended his lead to 50 seconds.
"I think we have taken a step forward today, but we need to keep paying attention to Horner who had a great stage today," Nibali said afterwards.
"In the end I managed to get on his wheel because he couldn't do any more, but there are still important stages to come."
Having been dropped with over 20km to go, Movistar's Valverde, the 2009 Vuelta winner, fought back bravely on the final climb to the finish line to lose just 50 seconds and remain in third place, 1min 42secs behind Nibali.
"I suffered a lot due to the weather. Today is a day to forget," said a shattered Valverde at the finish line.
"It was terrible, I felt very bad and we all were very cold. Descending I felt sick but once I started to climb and warmed up a bit I tried to reach the leading group. Despite everything I haven't lost much time."
However, it was a disastrous day for Roche as he dropped to sixth, more than four minutes off the lead, after finishing 3mins 29secs behind Nibali, the 2010 champion.
On a day when heavy rain and freezing conditions more than played their part, Ratto's teammate Ivan Basso and Spaniard Luis Leon Sanchez of Belkin were both forced to abandon the race due to hypothermia.
Sanchez had even been part of the early breakaway group that built up a lead of over eight minutes before the worst of the rain arrived, however after suffering a heavy fall on the descent from Envalira he and Basso were forced to pull out as the temperatures plummeted.
And Ratto admitted it had been a day of mixed emotions for Cannondale.
"This morning we were all going for Basso and it wasn't to be because he had to withdraw with hypothermia. I was in an ideal situation during the whole stage. It is strange that being a sprinter I won a mountain stage, but it is great to be able to do this."
"The descent with the rain benefited me, I tried to go out from the front and it all went well."
With conditions hindering the chasing peloton, Ratto took advantage to break away on his own and his lead was never seriously troubled, although he lost nearly three minutes on Nibali and Horner as he struggled up the climb to the finish.
Joaquim Rodriguez of Katusha, who had described the ride as "his stage" before the peloton set off on Saturday morning, finished fourth to also move up to fourth in the general classification, but he is now nearly three minutes behind Nibali.