The breakthrough came for the Bundesliga leaders in the 105th minute after 1860 midfielder Dominik Stahl brought down Marco Reus inside the area and was sent off, Pierre-Emerick Aubameyang sending Gabor Kiraly the wrong way with the resulting penalty.
Henrikh Mkhitaryan then added some gloss to the scoreline with a second moments later.
Bayer Leverkusen's 2-0 away win over Arminia Bielefeld was more straightforward but they had to wait until the second half to break down the hosts.
Heung-Min Son got the opener after 62 minutes and Sidney Sam made sure in the 89th minute.
Pierre-Michel Lasogga's 64th minute goal was enough for Hamburg to progress with a 1-0 win over Greuther Furth, while a 53rd minute strike from Marcel Risse gave Cologne a 1-0 win away to Mainz.
Diego scored on the stroke of half-time and Tomm Klose added a second eight minutes from time as Wolfsburg saw off VFR Aalen 2-0.
Hoffenheim's 3-0 winning margin against Cottbus looked convincing by the end of the night but they needed extra time after a frustrating 90 minutes, before goals from Niklas Sule, Roberto Firmino and Sven Schipplock finally put the visitors away.
Tobias Werner scored in the 45th and 57th minutes before Sascha Molders added a third just before the hour mark in a 3-0 win over Augsburg away to Preussen Munster.
Sandhausen came from behind to win 3-1 at Wiedenbruck.
Sebastian Sumelka put the hosts in front six minutes before half-time but Sandhausen turned it around after the break with three goals in the space of six minutes.
Ranislac Jovanovic levelled in the 62nd minute before quickfire strikes from David Ulm and Jovanovic again.
Wiedenbruck's misery was completed with the 82nd minute dismissal of Massih Wassey for a second bookable offence.