Farfan (centre) and Gavranovic scored Schalke's key goals
Two goals from Jefferson Farfan and one from Mario Gavranovic saw Schalke come from behind to beat Valencia and reach the last eight of the Champions League.
Valencia took just 17 minutes to cancel out Schalke's first-leg away goal as Ricardo Costa produced a smart header.
But Farfan levelled just before half-time with a superb free-kick.
Gavronovic then put Schalke ahead with a scrambled effort which hit both posts and went in before Farfan sealed things in injury-time with a clever chip.
Schalke came into the game in disappointing form and with question marks over the long-term future of coach Felix Magath.
They began brightly, but their early confidence evaporated when Mehmet Topal found space down the left and fired in a cross to which Costa reacted superbly, controlling a header past Manuel Neuer at his near post.
Schalke striker Raul headed wide soon after, but Valencia attacked against and Christoph Metzelder did well to block Aritz Aduriz's effort.
The Royal Blues looked set to go into the break still trailing but, with five minutes to go, they won a free-kick just outside the area.
It was a dangerous position, and Farfan made the most of it as he curled a superb free-kick into the top corner past Vicente Guaita, who got a fingertip to the ball but could not keep it out.
After the interval, Guaita could only push a cross down to Farfan inside the area, and although the Valencia goalkeeper managed to save the Schalke goalscorer's resulting shot, the ball fell perfectly for Gavranovic, whose effort hit the inside of the near post, rolled across the line and hit the far post as well before going in.
Schalke knew that a Valencia goal would put the Spanish side ahead on away goals, and they survived some nervy moments before the end.
Within four minutes of Gavranovic's goal Aduriz had two great chances to score, but he fired his first into the side netting with Neuer out of position and then, after being put clean through, he was denied by a brilliant save by the Schalke goalkeeper and captain.
Tino Costa then missed another good opening for Valencia while Neuer was called into action again to save a Juan Mata shot.
But Valencia could not force an equaliser and Schalke twice came close to killing the game off late on when Gavranovic hit the woodwork on separate occasions.
The first saw his thunderous drive deflected onto the near post by Guaita, and he then saw a brilliant 35-yard lob hit the Valencia crossbar with Guaita struggling.
Schalke were celebrating a third goal late on though as Farfan broke away before dinking the ball over Guaita to settle the contest.
Schalke double goalscorer Jefferson Farfan: "Two goals. That is very good but I am just happy the team is through, that is the most important thing.
"I hope I gave our fans something to smile about."
Schalke coach Felix Magath on rumours the board will end his contract at the end of the season: "It doesn't interest us, and it shouldn't interest us. The truth was plain to see on the field. I plan to continue my work until 2013.
"I am proud with how my players outplayed a top quality national team. We showed we are better when we face top teams."
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.