Australian Hansen timed a breakaway perfectly to clinch a fine solo victory on the 180-kilometre route from Salvaterra do Mino to Cangas do Morrazo on Friday.
The Lotto-Belisol man's victory may have surprised some, but Hansen believed the stage was tailor-made for him to challenge.
"I had told Greg Henderson earlier that this was a stage for me," he told his team's official website.
"After the climb there won't be many lead-out men left, so if I would attack it would be difficult to catch me. I had tried in one of the first stages as well, but then they caught me with 500 metres to go.
"When we had finished the descent Maxime [Monfort] and I were part of the first group and he said to me that I could have a go."
Tinkoff-Saxo rider Alberto Contador remains the outright leader ahead of Chris Froome, but the Spaniard believes he was lucky to avoid trouble following a fall from Froome's Team Sky team-mate Dario Cataldo.
"It was a difficult day with a very fast pace in the final part," Contador told Tinkoff-Saxo's official site. "I had to be well-positioned on the final short climb because we knew that it was a difficult descent, where the risk of crashes was high.
"I was very lucky to avoid being dragged down by Dario Cataldo's crash. I don't know how I did it, but I'm happy that I got through the day without any problems and I'm already thinking about [Saturday]."