Rangers and Celtic had contrasting experiences in the Europa League before both emerged victorious to join Tottenham in the play-offs.
Celtic needed a last-minute goal from substitute Mohamed Elyounoussi to edge past Riga while Rangers thrashed Willem II 4-0 away from home.
There were defeats on the road for Motherwell and Aberdeen but Irish champions Dundalk pulled off an away win.
Like the Scottish champions, Tottenham also came through a test as they beat Shkendija 3-1 in North Macedonia.
Erik Lamela put Spurs in front early on but a fine strike from Valmir Nafiu levelled matters after the interval.
However, weekend heroes Son Heung-min and Harry Kane came to the rescue.
Son added to the four goals he struck against Southampton when he scored on the rebound with 20 minutes left. Kane, who set up all of Son's goals and netted himself against Saints, then headed home from the South Korean's cross to seal a play-off against Maccabi Haifa.
Celtic were frustrated for large parts in the Latvian capital by Riga, who were cheered on by fans looking over the stadium wall in two double decker buses.
Hoops substitute Albian Ajeti failed to convert from a yard out as the tie looked set for extra-time but another replacement, Jeremie Frimpong, cut the ball back for Elyounoussi to sweep home.
Neil Lennon's side will next travel to Sarajevo, where they won 3-1 in last season's Champions League qualifiers.
Rangers were far more convincing in Holland, helped by two goals in three minutes midway through the first half.
James Tavernier netted a penalty and Ryan Kent pounced on a fumble from the goalkeeper to double the lead.
Defenders Filip Helander and Connor Goldson both headed home in the second half to set up an Ibrox clash with Galatasaray.
Declan Gallagher was sent off after being booked twice inside 60 seconds as Motherwell fell to a 3-0 defeat against Hapoel Beer-Sheva in Israel.
Motherwell had the better chances before Miguel Vitor scored from a free header following a 43rd-minute set-piece.
Gallagher missed a good chance before giving away a 71st-minute penalty which Josue converted as the defender walked down the tunnel following his red card. Hapoel's man advantage told and Elton Acolatse added a late third.
Aberdeen fell to an early goal from 18-year-old Tiago Tomas in Lisbon against a Sporting side missing nine players and their manager to positive Covid-19 tests.
Ryan Hedges came close late on for the Dons as they slumped to a 1-0 defeat.
Dundalk fell behind early on in against Sheriff Tiraspol but Sean Murray headed home a deserved equaliser in first-half stoppage-time to ultimately take the game to extra-time and penalties.
The visitors won the shoot-out 5-3 to set up a real chance of making the group stage with Faroese side KI to come in the play-offs in Ireland.