There were around 20,000 fans inside Kiev's Olympic Stadium, the venue where La Roja won Euro 2012 to cap an unprecedented four-year spell of dominance.
Spain had less to celebrate this time, though, as goalkeeper Georgi Bushchan made eight saves to keep Luis Enrique's side at bay before Viktor Tsygankov capitalised on some slack concentration at the back to score the winner 14 minutes from time.
Spain remains top of its group but there will be plenty to play for when the competition resumes next month.
Bushchan tipped over a header from Rodrigo Moreno as Spain started positively, and Ansu Fati should have done more than shoot straight at the keeper after Sergio Canales nudged the ball into his path.
Bushchan got fingertips to a Sergio Ramos free-kick, denying the defender a goal to mark his 175th international appearance, the same number as veteran Italy keeper Gianluigi Buffon.
Ukraine had just 21 per cent of the ball in the first half and scarcely got near David de Gea's goal, but it should have taken the lead early in the second, Oleksandr Zubkov dragging a shot well wide after Serhiy Sydorchuk put him clean through.
Ferran Torres and Mikel Oyarzabal came on to freshen the Spain attack, but it was Rodri who next came closest, whistling a low shot just wide of the left-hand post from the edge of the area.
Bushchan stayed big to deny Oyarzabal from close range and Ferran following a dazzling run, before his kick led to the breakthrough.
With Spain's midfield and defence out of position, Andriy Yarmolenko played in Tsygankov and he drove through the gap between the centre-backs to finish expertly past De Gea, who had strayed curiously far from his line.