Reigning European champions Spain claimed a 1-0 win in Kiev to consign Ukraine to a place in the playoffs.
Spain won an eighth successive match in advancing top of Euro 2016 qualifying Group C as Mario Gaspar's debut goal proved decisive.
Their only defeat came in their second game to Slovakia, who finished runners-up, with Euro 2012 co-hosts Ukraine third.
Ukraine began the match level on points with Slovakia, but an inferior head-to-head record meant they needed a better outcome than their rivals, who were playing in Luxembourg.
It was a challenging task at NSK Olimpiyskyi in Kiev against the 2008 and 2012 European champions and 2010 World Cup winners.
Vicente del Bosque selected an experimental lineup, but La Roja's reserves were keen to impress their coach.
Jose Mourinho watched on as Chelsea's Cesc Fabregas won his 100th Spain cap as captain in the stadium in which the Blues will play Dynamo Kiev in the Champions League next week.
Mourinho may also have been watching rumoured transfer target Andriy Yarmolenko, who plays for Dynamo Kiev.
David De Gea was busy in the early skirmishes, saving from Ruslan Rotan and Artem Kravets before the visitors took the lead.
Thiago Alcantara was played in on the left side of the area and crossed to the back post, where Villarreal's Gaspar headed in.
Fabregas spurned the opportunity to double the lead and mark his century of appearances with a goal within four minutes.
The playmaker had been fouled by Olexandr Kucher and took the spot-kick himself, only to see Andriy Pyatov make a save to his left.
The former Arsenal and Barcelona midfielder has now missed four from four penalties in normal play for Spain.
Mourinho, his club boss, would have been frustrated to see Fabregas denied, with the Blues short of confidence.
With Slovakia expected to win in Luxembourg, Ukraine knew they had to chase a victory themselves and the game became more open.
Isco and Thiago tried to manufacture a second for Spain and Mikel San Jose had the ball in the net, only for the effort to be ruled out for an infringement.
Yarmolenko struck the post with a left-footed shot following a team move and De Gea saved from Denys Garmash.
Rotan, Yaroslav Rakitskiy and Yevhen Konoplyanka went close, with De Gea tested, while Nolito and Xabier Etxeita were denied by Pyatov at the other end.
Ukraine were applying pressure, but Thiago missed a chance to settle it with a second late on from substitute Juan Mata's pass as the visitors prevailed.