Valverde put in a trademark uphill dig on the final ramp of the 210km stage from Estepona, the Movistar rider rounding Ireland's Nicolas Roche (Team Sky) and holding off Tinkoff-Saxo's Sagan to take his seventh win of the season.
Roche was pipped by Spaniard Dani Moreno (Katusha) for third place to stay within 15 seconds of Colombian race leader Esteban Chaves (Orica-GreenEdge), who holds onto the red jersey by five seconds over Dutchman Tom Dumoulin (Giant-Alpecin) with Roche poised in third place.
Valverde stayed in fifth place at 28 seconds – four seconds behind another Irishman, Dan Martin of Cannondale-Garmin, and seven seconds clear of compatriot Joaquim Rodriguez (Katusha).
Impressive Ganna tops opening Giro TT in Turin
Race favourites Nairo Quintana (Movistar) and Chris Froome (Team Sky) finished in a second group which was eventually awarded the same time as the leaders after an initial three-second deficit. They both retain their positions in the top ten.
Colombian Quintana is eighth at 36 seconds while Britain’s Froome is ninth place at 40 seconds, seven seconds ahead of tenth place Italian, Fabio Aru of Astana.
“Today my team stayed back because we have a long race ahead and we need to keep something back,” Valverde said after his latest win on home soil.
“We sat on with Katusha – we both rode very well and very tactically – and then for the last two hundred metres I flew. I knew Sagan was there on my wheel – I kept on getting flashes of his hair – but I knew I was the strongest and it was going to be my victory today.”
For his part, Sagan, winner of Monday’s stage three at Malaga, told Eurosport he struggled with the heat and said he was frustrated that Movistar did not lend a hand in chasing down a six-man group, which had built up a maximum lead of over thirteen minutes on the longest stage of the race.
“I spent a lot of time with my team-mates on the front of the group,” Sagan said. “I went to Alejandro Valverde to ask for Movistar to help but there was no interest.
“The final climb was steep and very hard. To be honest, I probably did too much work on the first part of the climb and then didn’t have the power in the final sprint.”
1- SIX-MAN BREAK
Frenchmen Mickael Delage (FDJ) and Jimmy Engoulvent (Europcar), Dutchman Bert Jan Lindeman (LottoNL-Jumbo), Belgian Nikolas Maes (Etixx-Quick Step), Croatian Kristijan Durasek (Lampre-Merida) and Spaniard Markel Irizar (Trek) attacked from the gun to quickly establish a hefty lead over the peloton.
With no categorised climbs on the agenda, the escapees managed to build up a lead of 13:30 after just 30km before the Orica-GreenEdge team of race leader Chaves and in-form Sagan’s Tinkoff-Saxo squad combined to slash the deficit.
Two thirds of the break threw in the towel with 26km remaining to leave veterans Engoulvent and Irizar as the last men standing. The 35-year-old thoroughbreds staved off the inevitable until 11km remained, with Tinkoff-Saxo still firmly in control of proceedings.
2- VAN GARDEREN CRASH
The main flashpoint of an otherwise rather sedate stage in sunny southern Spain was a crash involving Americans Ben King (Cannondale-Garmin) and Tejay Van Garderen (BMC).
King went over the handlebars after overcooking the narrow exit from a roundabout 33km the finish and Van Garderen was caught up in the subsequent melee.
After a frantic chase back on with three BMC team-mates, Van Garderen rejoined the peloton and despite cuts to his knee and elbow finished alongside the likes of Aru and Froome in the main pack.
There was less luck for his fellow American Andrew Talansky, King’s Cannondale-Garmin team-mate, who was involved in both the crash and a subsequent mechanical before coming home more than four minutes in arrears.
3. FRANTIC FINAL FOUR
The Giant-Alpecin team-mates of Dumoulin and John Degenkolb led the pack onto the final climb 4km from the finish before Belgian Tosh van der Sande (Cofidis) put in the first attack, only to be passed by Spaniard Pello Bilbao of Caja Rural.
With Katusha leading the chase, Bilbao grappled with the steep 18% ramps of the narrow climb into Vejer de la Frontera before being caught when the road flattened out with 2km remaining.
Spanish veteran Samuel Sanchez (BMC) then zipped off the front with Roche, the pair building up a tasty lead on the penultimate rise before the finish. The leading duo looked set to contest the final win when the road dropped down inside the final kilometre, but the stinging ramp inside the final 250 metres saw Valverde make his move.
Valverde, who admitted to having studied the finish on Googlemaps ahead of the race, surged out of the saddle, passing Roche and holding off a fatigued Sagan.
The line came unexpectedly soon and on a tight left-hand bend; had there been another 50 metres of flat, Sagan could well have made it two from two. As it was, victory went to evergreen Valverde – twelve years after his maiden Vuelta win in 2003.
Giro d'Italia jersey rankings and standings
'I have a choice' - Sagan plays down next move ahead of Giro