Stars thought they had the victory in the bag in ordinary time when Edward Manqele netted a brilliant goal, but Daine Klate equalised with a free-kick six minutes into injury-time.
But Paulus Masehe headed home from a corner in extra-time to break the hearts of his former side and send Ea Lla Koto through.
It brings to an end a run of 10 Cup matches without defeat for Pirates, who last lost in the final of the 2010 Telkom Knockout to Kaizer Chiefs.
After an emotionally draining week in which they defeated Soweto rivals Chiefs and kept League leaders Mamelodi Sundowns to a 0-0 draw, the Buccaneers players looked tired in a game that Stars deserved to win.
Indeed, Pirates goalkeeper Moeneeb Josephs was forced to make a number of fine saves to keep his side in the contest as Stars produced arguably their best performance of the season.
Stars were ahead on 69 minutes when new Bafana Bafana cap Manqele produced a magnificent finish with a neat lob over Josephs to confirm his status as a rising star of the local game.
It looked as though the visitors would hold on until Pirates won a free-kick in the 96th-minute of the game and Klate produced a powerful finish that left Kennedy Mweene in the Stars goal leaden-footed.
Penalties looked a distinct possibility as both sides ran out of steam in extra-time, until Masehe got to a corner ahead of Josephs in the 114th-mianute and headed home for a famous Stars win.