Bordeaux, leading 1-0 from the first leg, went further clear through an early Yoann Gourcuff free-kick and with the visitors down to 10 men from the 60th minute they appeared to have the tie firmly in hand.
Not so. The Greek side levelled through Kostas Mitroglou in the 65th minute and Bordeaux were reeling when captain Alou Diarra was sent off three minutes later.
Bordeaux held their nerve, though, and a goal from Marouane Chamakh two minutes from time sealed a 3-1 aggregate win that took them through along with Olympique Lyon - the first time France have had two teams in the quarter-finals since 2004.
NEWS: Gourcuff revives Zidane comparisons
"We made it hard for ourselves in the second half," Gourcuff told French TV channel Canal Plus. "But we had a fantastic first half, we should actually have been 2-0 or 3-0 up at the break."
"Now, we just hope to avoid Barcelona," coach Laurent Blanc told reporters.
His Olympiakos counterpart, Bozidar Bandovic, said: "Congratulations to Bordeaux. I think we were the better side in the second half. If the players had had more self belief, it could have been a different story."
Bordeaux got off to a dream start, with Gourcuff scoring from the edge of the box with a whipped free kick into the far top corner.
Blanc's side, who had conceded only two goals from eight games in the competition, could have secured their qualification before the break.
Gourcuff collected a lobbed pass from Benoit Tremoulinas before rushing through the defence only to be denied by goalkeeper Antonis Nikopolidis, who dived at his feet, in the 40th minute.
Four minutes later, the former AC Milan player fired another free kick that smashed the bar.
Olympiakos, reduced to 10 men when Matt Derbyshire was sent off for a second booking with an hour gone, looked thoroughly beaten but turned the tide.
Mitroglou fired home a stunning volley from a throw-in and Bordeaux were also reduced to 10 men when Diarra got his second yellow card.
Bordeaux's game deteriorated but the French champions held on until Chamakh sealed their progress when he headed home at the far post from a Tremoulinas cross.
Olympiakos even ended up with nine men when Olof Mellberg was sent off long after the 90 minutes were up.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.