With the aggregate score tied at 4-4 after a pulsating 120 minutes in the semi-final second leg, Simon Moore saved Miles Storey's penalty before Adam Forshaw fired in the winning spot-kick to seal the Bees' place in the Wembley final against Yeovil Town later this month.
Adam Rooney's unfortunate own goal opened the scoring, before Clayton Donaldson's neat turn and shot doubled the Bees' lead. Rooney made amends moments later, putting the Robins back in it from close range.
Donaldson extended the home side's lead, finishing well after intercepting Gary Roberts' wayward pass, but goals from Joe Devera and a late Aden Flint header sent the tie into extra-time.
Brentford were gifted a 24th-minute lead when Harry Forrester whipped in a corner and Rooney diverted the ball past his own keeper.
The Bees sensed they could kill Swindon off in the first half and recalled striker Trotta thumped a shot against a post, and they got their second in the 40th minute when Donaldson collected the ball on the edge of the Swindon area and slotted a low drive past Wes Foderingham into the corner of the net.
But Swindon were thrown a lifeline before the interval when Tom Adeyemi and Toumani Diagouraga got themselves into an almighty muddle on the halfway line. Town broke clear through Gary Roberts, and when his shot was blocked, Rooney was on hand to tuck in the rebound.
However, Roberts suffered brain freeze moments after the restart when his sloppy pass on the halfway line sent Donaldson racing towards goal before coolly dinking the ball over Foderingham to restore Brentford's two-goal advantage.
Yet Swindon refused to go away quietly and in the 57th minute, when Brentford failed to clear Raffaele De Vita's corner, Devera swept the loose ball high into the net.
Bees substitute Sam Saunders could have wrapped up victory but his curler clipped the crossbar, and instead, five minutes into stoppage-time, Flint nodded in Roberts' corner to stun the hosts again and take the tie into extra time.
Swindon were reduced to 10 men when Nathan Byrne was shown a second yellow for deliberate handball and Foderingham twice saved from Donaldson to take the tie to penalties.
But the Bees kept their nerve in the shoot-out and Forshaw's effort sparked a pitch invasion and wild scenes of celebration, relief and disbelief.