BERLIN, Jan 30 (Reuters) - VfL Wolfsburg came back from the brink to knock Schalke 04 out of the German Cup with a 5-3 victory on penalties on Wednesday. Schalke took the lead through Peter Lovenkrands in the 27th minute and were heading for victory and a place in the quarter-finals before a last-minute strike from Sergej Karimov forced extra-time. After a goalless 30 minutes Wolfsburg took the upper hand against their Bundesliga rivals when newly signed Swiss keeper Diego Benaglio saved in the shoot-out from Mladen Krstajic. VfB Stuttgart, last season's runners-up, just managed to avoid a similar fate, as a Mario Gomez hat-trick gave them a 3-2 win over Werder Bremen Amateurs. Gomez's goals gave Stuttgart a 3-0 lead going into halftime but Werder's second team, who play in the regional third division, cut the deficit with goals from Marc Heider and Dominic Peitz to give the favourites a real scare. Hamburg SV had a more comfortable 3-0 win over third division Rot-Weiss Essen to book their place in the last eight. Bundesliga side Arminia Bielefeld went out after a 2-1 loss to second division Carl Zeiss Jena. Bayern Munich, 5-2 winners over third division Wuppertal, were one of four teams to come through on Tuesday night. The Bundesliga leaders were joined by neighbours TSV 1860 Munich and Hoffenheim, both of the second division, and Borussia Dortmund, who beat Werder Bremen 2-1 in what was a bad week for the club.