The Premiership side dominated the early possession in the fifth-round tie at Palmerston Park with David McKay seeing his shot blocked inside the first 10 minutes of the game.
The away side fashioned the first clear-cut opportunity but Danny Swanson saw his long-range effort saved by Jim Atkinson.
But Queen of the South improved as the half went on with Lyle, Michael Paton and Kevin Holt all having shots which failed to find the target.
The home side almost made their possession advantage count just before half-time but Ian McShane’s shot from distance was saved by Alan Mannus.
Queen of the South started the second half as they began the first and had to wait only three minutes before taking a deserved lead.
St Johnstone goalkeeper Mannus made a double save to deny Paul Burns and then Lewis Kidd, but Lyle was on hand to stab home the rebound from close range.
Queens continued on the ascendancy with Reilly creating a couple of opportunities before Lyle forced another good save from Mannus.
Murray Davidson was inches away from equalising for St Johnstone with a header but Atkinson got down brilliantly to deny the midfielder.
Reilly then tested Mannus at the other end before James McFadden went close for the visitors.
But Queens sealed the win in added time when Reilly slotted home from close range to put the Dumfries side into the quarter-finals for the first time in seven years.