Goals from Valter Birsa and Nejc Pecnik helped Slovenia topple Slovakia 2-0 in a 2010 FIFA World Cup South Africa qualifier in Bratislava that all but secured the top two spots in Group 3 for both teams.

Slovakia, which needed a point to go straight to South Africa, now top Group 3 with 19 points, ahead of Slovenia which have 17 points and face minnows San Marino in the last qualifier on Wednesday, while Slovakia travel to Poland.

Auxerre midfielder Birsa put Slovenia ahead in the 56th minute with a shot from 20 metres that swerved across the box and into the top corner. Pecnik then sealed Slovenia's victory just before the final whistle.

Slovenia need only to beat San Marino - bottom of the group having lost all nine games, scoring one goal and conceding 44 - to assure themselves of second place and push for top spot.

Slovakia, meanwhile, must win in Poland to assure themselves of an automatic presence in South Africa, while the result also meant the Czech Republic's win over the Poles counted for little.

Second-half goals from substitute Tomas Necid and Jaroslav Plasil earned Ivan Hasek's team the three points after forward Milan Baros was denied by an offside flag before the interval. But they still trail Slovenia by two points and must therefore beat Northern Ireland at home in Wednesday's final game and also rely on San Marino - beaten 5-0 in Maribor in August - springing one of the all-time great shocks.