The Perth outfit stunned the 22-time Norwegian champions with Frazer Wright's winner in Trondheim and then completed the job at McDiarmid as young striker Stevie May netted a precious equaliser to secure safe passage to the third qualifying round.
The incredible two-leg victory is Tommy Wright's first act as new Saints boss and sets up a meeting with Beluarusians FC Minsk.
Wright had downplayed his side's chances ahead of the match but his attempts were laughed off by Rosenborg coach Per Joar Hansen as merely "mind games".
The Perth boss had suggested that the Norwegians were favourites to go through and tried to heap pressure on the visitors by claiming that an early exit for the former Champions League quarter-finalists would be seen as a "disaster" in their homeland.
The ploy worked a treat as St Johnstone refused to let an early strike for the visitors unsettle their hopes of progressing and worked doggedly in the closing stages to hold off a succession of Rosenborg attacks.
Alexander Soderlund was making his first start for the Norwegian champions and got off to the perfect start when he found the corner of the net after firing between Wright's legs just four minutes in.
A wayward Gary McDonald pass soon after almost had the home side undone for a second time but St Johnstone held their nerve and levelled when Rosenborg defender Mikael Dorsin paused long enough to allow May to pounce on a David Wotherspoon pass and prod past goalkeeper Daniel Orlund.
Nigel Hasselbaink could have made the final stages a lot more comfortable had he taken a decent opening on 33 minutes.
But after putting that effort wide, St Johnstone had to rely on their own shot-stopper, as Alan Mannus turned away second-half attempts by Nicki Nielsen and Borek Dockal to confirm the win.