The Astana rider held off Roglic (LottoNL-Jumbo) to take the 164.7km stage from Vitoria to Eibar with Ion Izagirre (Bahrain-Merida) third.
"It was not easy to go in a break, but finally, I was able to follow the decisive attack to catch the right group," Fraile said. "It was a group with a lot of good riders and we worked pretty well.
"I knew the last climb and as it was expected, there was a headwind. So, when I saw the group of the leader is coming close, I decided to wait for them and to join that group.
"I knew I could stay with them until the top and later of the descent, which I knew perfectly as well. It was impossible to make any difference on the descent and I saw everything is coming to a sprint.
"I tried to do it smart inside the final kilometres and in the sprint just gave my all to win this stage."
Roglic leads Movistar's Landa, who finished 6th out of the leading group, by 1min 57sec while Izagirre is in third at 2min 13sec.
With eight categorised climbs over 122km set for the final day of racing, Landa said he was going to work to dislodge Roglic from the top spot.
"We were seventh yesterday and we now sit on the podium. Let’s hope Roglic suffered a bid today and our strategy pays off tomorrow. One step at a time," Landa said.
“We’ve got a more secure podium place now, but we must try and go for the leader’s jersey tomorrow.
"Any energy left to attack? Well, we’ll see tomorrow when the right time comes, but I’m really willing to do. We must try to do some harm tomorrow, until the very last kilometre."