The host needed just a point in Monday's qualifier to secure a top-two finish in Group B, but picked up all three as it inflicted a first defeat in 14 games on the reigning European champion.
First-half strikes from Roman Yaremchuk and Andriy Yarmolenko earned victory for Ukraine, which held on with 10 men after Taras Stepanenko was shown a second yellow card for handling the ball inside the box.
Ronaldo scored the resulting penalty 72 minutes in to bring up his personal landmark, but Portugal could not find a leveller and may now need victories over Lithuania and Luxembourg in their final two matches to hold off third-placed Serbia.
The group's top two entered the match in fine form but it was Ukraine which settled the better, opening up a two-goal lead inside 27 minutes.
Yaremchuk converted from close range after Rui Patricio parried Sergey Krivtsov's header six minutes in and Yarmolenko added a second before the half-hour mark, the West Ham midfielder getting between two defenders to convert Vitalii Mykolenko's cross.
Santos brought on Joao Felix at half-time and Portugal looked brighter after the break, with Ronaldo forcing Andriy Pyatov into a couple of fine saves inside seven minutes of the restart.
Ronaldo did pull one back from the spot after Stepanenko was adjudged to have handled the ball and the visitors nearly snatched a point at the death - Danilo Pereira's strike crashing back off the crossbar in added time.