Taking the overall lead from BMC's Tejay van Garderen, Valverde (Movistar) moved 21 seconds clear of Froome (Sky) on the general classification and 47 ahead of Contador (Trek-Segafredo).
He broke clear in the final 2km to finish 13 seconds ahead of Froome and Contador leading the way in the 182km mountain stage from Valls to Lo Port.
"It was a spectacular day for both myself and the team, I'm so glad I could finish this off,” Valverde said. “It was an amazing day, all thanks to my team-mates.
“We kept full focus in the dangerous part of the stage, exposed to the wind, and all over the stage, I had different team-mates surrounding me.
“At the final climb, Rubén Fernández and Marc Soler did a sensational job for me. From the very foot of the climb I was feeling like I had good legs, and I asked them to go on full steam for as long as they could.
“At the final two kilometres, I sought for my distance and launched the move with a pace I could hold until the line.
"It's a victory and a leader's jersey really special, because of everything that happened during the last few days. Things like those, outside the racing itself, are not ones that we like. In the end, we managed to get people excited and happy about our racing, and that's what counts.”
Valverde also won stage three at the top of La Molina on Wednesday, a day after he and his Movistar team mates were handed a one-minute penalty for illegal pushing during Tuesday's team time trial.
Orica-Scott's Adam Yates was in the mix during the final four kilometres, finishing fifth behind the leaders and in that position on the general classification.
It took 60km before a 15-rider group was able to establish a small separation from the main peloton with their efforts lasting to the decisive eight-kilometre climb of the stage.
From that point, it was a war of attrition with Movistar doing the work necessary to narrow the peloton down to just Valverde, Froome, Contador, Yates and Marc Soler (Movistar).
Van Garderen finished in 22nd place at 1min 53sec behind Valverde to cede his leading position and is now 6th overall at 1min 18sec.