The Spaniard triumphed atop the 12-kilometre final climb in a dramatic final few kilometres that saw late attacker Anthon Charmig (Uno-X) caught just 300 metres from the line.
Charmig had attacked with 1.7 kilometres to go, dropping his rivals, but the 15 per cent gradients began to tell, and he slowed dramatically in the final kilometre.
Díaz produced a more measured climb along with others, including Australian neo-professional Jay Vine and it was a three-up sprint for the line. Vine launched first but Díaz was able to produce a final burst of acceleration to win the day and take over the race lead from previous leader Mark Cavendish (Deceuninck-QuickStep).
“I was confident for a good result and the team trusted me for that. It was a hard finale. Going into the finish, I wasn’t having my best moment. In the last kilometre, a rider went away but I recovered well and eventually I managed to catch him,” Díaz said.
“Only 50 metres before the line, I realized it was possible to win. It was very close to the line. But with 300 metres to go, any of the five riders at the front was able to win.
Vine finished second on the day and now sits second overall, with Eduardo Sepulveda (Androni Giocattoli - Sidermec) in third.
“The team had total faith in me today," said Vine. "We’ve come here with one goal, which is to get a stage win. We’ve been so close with Jasper for the first four stages. I think it’s really incredible how we came together. For a lot of us, it’s our first race of the year and our first together. To get four seconds now is really good, it’s also disappointing that we haven’t got our stage win yet.
"But I think we have got a really good group of guys here. Today we did it with four and everyone did an amazing job. It’s pretty surreal being put in position by Jasper on that final climb. That was pretty awesome!”
Vine is one of Australia's newest representatives on the professional scene, having won a contract with ProSeries squad Alpecin-Fenix through the Zwift Academy after impressing on the Australian domestic scene.