The Spaniard completed the 195.5km stage from Linares in 4:35:54, just ahead of world champion Peter Sagan of Bora-Hansgrohe.
Dutchman Danny von Poppel, whose LottoNL-Jumbo team had dominated the final kilometre, rounded out the podium.
France’s Rudy Molard (Groupama-FDJ) finished safely in the main group to retain his overall lead (31:20:34) and with it the red jersey.
Valverde (Movistar) trails the leader by 37 seconds with German Emanuel Buchmann (Bora-Hansgrohe) lying third, 48 seconds behind.
Almost immediately after the start a breakaway of three formed comprising Tiago Machado (Katusha-Alpecin), Jorge Cubero (Burgos-BH) and Héctor Sáez (Euskadi-Murias).
The peloton showed no immediate intention of catching the trio as the gap grew to 12 minutes with just under 120km remaining.
However, after the peloton went over the day’s categorised climb, with teams such as Trek-Segafredo and Bora-Hansgrohe setting the pace, they started to close in on the leaders.
With 14km remaining the gap dropped to only a minute and later, 8km from the finish, the chasing pack was just 15 seconds behind.
Machado then upped his pace in a bid to drop Cubero and Sáez, but his efforts were inadequate as he got caught with under 6km remaining.
Then, with just a kilometre to go, riders from teams such as Astana, Sky, Movistar, LottoNL-Jumbo and Bora-Hansgrohe started to position themselves at the front.
About 150m from the end Sagan was the first to make a move, but in the ensuing battle he was outsprinted by Valverde.
Valverde said he had been told beforehand that it was a difficult stage where riders could even lose time.
“My DS [directeur sportif] told me to get on Sagan’s wheel but I told him I am not going to go for the stage today; I am going to focus on not losing time.
“But in the end I got on Sagan’s wheel and was able to get past him.”
He concluded by saying he knew he was in good shape but he was surprised with the victory.