Stuttgart, who came 16th this season having finished just four points adrift of third place in 2017/18, twice took the lead at a sold-out Mercedes-Benz Arena but Union levelled both times.
The second leg takes place in Berlin on Monday, where Union have the chance to follow already-promoted Cologne and Paderborn up from the second division.
Union had the better of the chances in the opening half-hour with Stuttgart goalkeeper Ron-Robert Zieler somehow managing to deflect Sebastian Andersson's close-range effort onto the roof of the net.
Top-flight Stuttgart had produced little to worry the visitors for the majority of the first half but that all changed in the 42nd minute when they took the lead through Christian Gentner, who finished off a superb run down the right by Anastasios Donis.
That advantage lasted less than a minute, however, as Union equalised almost straight from the restart when Suleiman Abdullahi latched onto Andersson's flick-on before beating Zieler.
Stuttgart sent on former Germany striker Mario Gomez at the break and he needed just six minutes to put his side back in front.
The veteran hitman raced from inside his own half before unleashing a shot that took a heavy deflection off Union defender Marvin Friedrich – hitting his foot and then his face – to beat the wrong-footed Rafal Gikiewicz.
Once more, though, Stuttgart could not hold onto their lead as Friedrich made it 2-2 in the 68th minute when he powered home a downward header from a corner.
Union might well have snatched a winner in the closing stages but Zieler produced a stunning one-handed save in the 79th minute to tip over Andersson's equally brilliant dipping shot, before repeating the feat from the Sweden striker's stoppage-time header.