Schalke confirmed their place in the Champions League knockout phase with a 2-0 home win against 10-man FC Basel on Wednesday to finish second behind Chelsea in Group E.
Goals after the break by Germany's Julian Draxler and a strange second from Cameroon midfielder Joel Matip put Schalke in the last 16 to ease the pressure on under-fire coach Jens Keller.
The 43-year-old has been told a decision on his future will be made over the winter break in the wake of the Royal Blues' erratic form this season.
Having been knocked out of the German Cup last week and trailing leaders Bayern Munich by 17 points in the Bundesliga, Keller would have been set for dismissal after a year in charge had Schalke failed to go through.
Schalke's successful qualification will see them earn 4.5 million euros (US$6.2m).
"No one can understand the pressure the team and I were under," said Keller.
"The joy in winning a game like that is huge.
"No one had given us any credit.
"The fact we have reached the knock-out phase is hugely important for the club, especially financially."
The win comes at a cost for Schalke as both Draxler and captain Benedikt Hoewedes face spells on the sidelines having suffered torn leg ligaments.
The Royal Blues had to win to go through and faced 10 men for an hour as FC Basel had centre-back Ivan Ivanov, who cleared an early shot off the line, sent off for holding back Schalke's Adam Szalai on 31 minutes.
Hoewedes was lucky not to be shown a red card, instead of the yellow he received, on 29 minutes, as he injured himself with a rugby-style tackle on Basel captain Marco Streller, who would have been clear on goal.
The breakthrough Schalke desperately needed came on 50 minutes when Farfan swung in a cross and found Draxler unmarked at the far post to slam home his shot and give the Royal Blues the lead.
Schalke secured their passage to the knockout phase seven minutes later when their second goal arrived in bizarre fashion.
Replays showed that five Schalke players were offside as the ball came into the box from a Farfan free-kick, but the assistant referee did not raise his flag and Matip was left alone to slot past Basel goalkeeper Yann Sommer.
"I had my eyes on the linesman, who didn't react. I was suprised by that," admitted Matip.
Basel coach Murat Yakin was left protesting incredulously on the sidelines, but the defeat means the Swiss champions finish third in the group and drop into the Europa League.
"We started the game well, our passing was good, we kept calm and had a lot of possession," said Yakin after the final whistle.
"Unfortunately, we then had a player sent off, which unbalanced the team."
After reigning champions Bayern Munich and Bayer Leverkusen qualified on Tuesday, Schalke joined last season's runners-up Borussia Dortmund in progressing to the last 16 on Wednesday as all four Bundesliga sides reached the knockout phase.