Spain have moved to the top of Group C after ending Slovakia's unbeaten record in Oviedo.
Goals from Jordi Alba and Andres Iniesta mean that La Roja go into first on goal difference, with three games remaining.
The Barcelona defender took advantage of a lapse in the Slovakia backline to race onto David Silva's measured diagonal ball before heading past Matus Kozacik.
Alba nearly netted a second when another cross from Juanfran was met by the full-back, but this time his header was off-target.
Spain were then awarded a penalty after 30 minutes after Kozacik was deemed to have tripped Diego Costa, although replays suggest that contact was minimal.
Iniesta calmly stroked the spot kick into the bottom corner as La Roja looked to be cruising towards the top of the group.
Slovakia, who had won all six of their previous qualifiers, nearly pulled a goal before the break when Marek Hamsik took aim at goal, only to be denied by Iker Casillas.
Substitute Michal Duris caused problems for Spain early in the second half, dragging one shot wide before forcing another save out of Casillas soon after.
Santi Cazorla came close to adding a third with a shot that curled wide of Kozacik's goal, but otherwise La Roja managed to see out a comfortable victory that puts them ahead of Slovakia, while Ukraine are three points behind after their win against Belarus.