A late split in the pack on the hilly stage to Fisterre, won by Spain's Dani Moreno, allowed Giro d'Italia winner Nibali to move ahead of American Chris Horner and claim the lead.
"I'm surprised, I had no idea there was a gap and didn't know I was leader, I was on the team bus," said Nibali, who was rushed back to the finish area in a team van so he could accept the leader's jersey.
"I wasn't looking for the leader's jersey, all I wanted to do was stay in the front group and keep things under control," he added.
"I knew that Chris and his team wanted to keep the lead, you could see that from the way they worked hard on the front on a difficult stage all day."
Nibali now leads by three seconds from Horner with Ireland's Nicolas Roche eight seconds further back.
"I got boxed in, the split was right at the finish and there was no way to move out in any direction," Horner, who finished 26th, six seconds back, told Reuters.
The American, who at nearly 42 became the oldest Grand Tour leader when he captured the top spot on Monday, said he would attack in the mountains to try to get the leader's jersey back later in the race.
As the pack fragmented on the ascent to Fisterre lighthouse on Galicia's Atlantic coastline, Moreno put aside his usual duties as lieutenant for overall contender and Katusha team mate Joaquim Rodriguez by sprinting to victory.
A late attack by Swiss Fabian Cancellara brought the former Olympic and world time trial Champion to within a few metres of Moreno, who dug deep to claim the second Vuelta victory of his career. Australian Michael Matthews was third.
Moreno, winner of the Fleche Wallone Classic in the spring, said he had told his room-mate Joaquim Rodriguez that he wanted to win the stage.
"He said to go for it," Moreno said.
After moving up to eighth place overall, eight places ahead of Rodriguez thanks to Tuesday's win, Moreno said there would not be a switch in the leadership in his favour after his strong race start.
"I will be back to work for Joaquim again tomorrow although stage nine's summit finish is another personal target," he said.
The race finishes in Madrid on September 15.