A last-minute goal from Adam Szalai was enough for German side Schalke to see off PAOK and make it through to the group stages of the Champions League.
The Bundesliga side but went ahead when Szalai converted Atsuto Uchida's cross.
Stefanos Athanasiadis blasted in an equalizer for the hosts at the start of the second half, and their chances of advancing appeared to have been boosted when Schalke were reduced to 10 men when Jermaine Jones was shown a second yellow card.
But Julian Draxler restored the German side's lead three minutes later from a tight angle after rounding goalkeeper Jacobo.
Although Kostas Katsouranis headed PAOK level from Miroslav Stochin's free-kick, Szalai struck again at the death to ensure Schalke will play in the group stage for the sixth time.
Steaua Bucharest will be in the group stage draw for the first time in five years after drawing 2-2 at Legia Warsaw to go through on away goals after the first leg finished 1-1.
Basel, already leading Bulgarian side Ludogorets Razgrad 4-2, won 2-0 on home soil to cruise into Thursday's draw where they will be joined by Austria Vienna, who squeezed through 4-3 on aggregate, despite losing 3-2 on the night at home to Dinamo Zagreb.