Four-time champions Leinster came into the contest as Pool 1 winners after securing six victories from as many matches while Saracens finished second in Pool 4, but it was the visitors who dominated the first half with five penalties.
Alex Goode, who came into the Saracens side as a replacement for suspended England skipper Owen Farrell, then converted after scoring a late try to give his team a 22-3 lead at the end of the opening period.
Leinster, who had won their last 18 games at the Aviva, responded with tries through Andrew Porter and Jordan Larmour after the restart, with Johnny Sexton converting on both occasions to cut the deficit to five points at 17-22.
Saracens missed two penalties late in the game before Goode scored one with 10 seconds remaining to seal the victory.
It was Leinster's first defeat of any sort since they lost to Saracens in last year's final.
Saracens are set to drop into England's second tier at the end of the 2019-20 Premiership campaign after being relegated for breaching salary cap rules and will not be allowed to compete in Europe as a second-tier club next season.
They will now face the winner of Saturday's second quarter-final in which French Top14 sides Clermont Auvergne and Racing 92 -- top sides in Pool 3 and 4 -- face off at Stade Marcel-Michelin.
The two French teams have lost five of the last seven finals between them. (Reporting by Shrivathsa Sridhar in Bengaluru Editing by Ian Chadband)