Primoz Roglic finished third to tighten his grip on first place with just Sunday's time trial to come.
The 28-year-old Irishman had collected his first Grand Tour stage win nine days earlier.
"Moments like his don't come around too often," Dunbar said at the line.
"I've had two of them in the last two weeks. I'm just looking forward to sharing these moments and celebrating them with friends and family."
Spaniard Enric Mas chased Dunbar across the line, seven seconds back after the 172km run from Villarcayo.
Slovenian Roglic was three seconds further behind.
Ben O'Connor, who surrendered his race lead the day before, fought hard to protect his second place crossing the line in sixth, 14 seconds behind Dunbar.
The Australian did enough to end the day nine seconds ahead of Mas.
Roglic increased his lead to 2min 2sec although his Red Bull Bora Hansgrohe faced some disruption when a member of staff was reportedly hospitalised earlier with food poisoning.
"I am quite fine for the moment," said the Slovenian at the finish, adding that he was not taking a fourth Vuelta title for granted ahead of Sunday's 24.6km race against the clock.
"We just have to finish it off. It's that simple," Roglic said.
Dunbar, who rides for Jayco Alula, had won in Padron on stage 11 by sprinting away from a breakaway group.
"This one feels sweeter," he said at Saturday's finish.
"I said to a few people after the stage win last week that it was not how I expected to win a Grand Tour stage. I always imagined winning at the top of a climb."
This time, he broke away from the group of race leaders with five kilometres left on the final climb, caught escapee Pavel Sivakov with 3.5km left and then sped away with 2km to go.
He struggled to the line, looking over his shoulder at the heavyweight group closing in as they battled for second in the overall classification.
"I just felt good. I backed myself in that climb and paced myself well," Dunbar said.
"I rode the steep parts pretty hard and the flat bits pretty conservative to make sure I had enough in the tank."
"I've had good times and I've had bad times and it's all part of the process. There's going to be more ups and there's going to be more downs. That's just the way life is."