LUXEMBOURG (AP) Slovakia beat Luxembourg 4-2 on Monday to advance to the European Championship for the first time as an independent nation.

The win against the already eliminated Luxembourg secured Slovakia second place in Group C and an automatic spot at Euro 2016 in France.

Group winner Spain, which had already qualified in advance, defeated Ukraine 1-0 in Kiev, sending the hosts to the playoffs.

More from FoxSports

Spain finished with 27 points from 10 matches, while Slovakia ended with 22 points and Ukraine stayed with 19.

Slovakia hadn't scored in three games but ended the goal drought in a six-minute span at the Josy Barthel Stadium in Luxembourg.

Marek Hamsik got on the board in the 24th, Adam Nemec scored in the 29th and Robert Mak netted in the 30th. Luxembourg made it interesting with goals by Mario Mutsch in the 61st and Lars Gerson in the 65th, but Hamsik sealed Slovakia's victory in injury time.

Slovakia last played at the European Championship in 1992 as member of Czechoslovakia.

Ukraine played well and had a series of scoring chances against Spain, but it was stopped by a remarkable performance by Spain goalkeeper David De Gea.

''We knew it was going to be tough given Ukraine needed a win,'' De Gea said. ''I always try and do my best. I had a great game and the important thing was to get the win under our belts. I give my all and today had some luck. I need to carry on like that.''

Gaspar gave Spain the lead in the 22nd minute with a header from near the far post after a cross by Thiago Alcantara. Cesc Fabregas had a chance to increase the lead from the penalty spot two minutes later after being brought down by defender Olexandr Kucher inside the area, but goalkeeper Andriy Pyatov made a great right-handed save.

The game was played at a packed Olympic Stadium in Kiev, the same site where Spain won the European title in 2012.

Among those in the crowd was Chelsea's Portuguese coach Jose Mourinho.

In the other Group C match, Belarus and last-place Macedonia played to a scoreless draw.