Liam Kelly salvaged a point and with it the tenuous title hopes of St Patrick's Athletic with an 84th-minute equaliser from the penalty spot at Tolka Park.
But seconds later the striker spurned the opportunity to close the gap with Shelbourne to three points as he blazed a second penalty over the crossbar. Trailing from Sean Francis's fourth-minute goal, St Patrick's got back into the game when referee Dick O'Hanlon ruled that Pascal Vaudequin had pushed Darragh Maguire. Kelly sent goalkeeper Tony O'Dowd the wrong way with the kick.
Less than minute later Robbie Griffin put Ger McCarthy away down the right and he was tripped inside the area by Gareth Cronin to concede a second penalty. Kelly, however, shot over the bar this time.
Rovers, chastened by their Cup exit to Bohemians on Friday, rung the changes, with Tommy Dunne, Pat Deans and Marc Kenny coming into their starting 11. And it was from a third successive corner on four minutes from Kenny, making his first start in exactly four months since injuring himself against St Patrick's, that Rovers scored. Kenny forced the second of those corners when his curling right-foot shot needed an agile tip-over save from Shay Kelly.
His third corner was played short to Vaudequin, who whipped the ball into the crowded area containing all 11 St Patrick's players. Brian Byrne's point-blank shot was blocked by Kelly, but only as far as Francis who drilled home a right-foot shot.
St Patrick's survived another scare on the half hour when Dunne set up Byrne who shot over the top. Tony O'Dowd, in the Rovers goal, then did well to tip away a shot from Ger McCarthy as St Patrick's finished the half strongly.
The second-half was a huge disappointment until that dramatic final few minutes.
Shamrock Rovers: O'Dowd; Vaudequin, Palmer, Cronin, Dunne; Kenny, Deans, Tracey, Byrne; Francis, Grant. Subs: Cousins for Grant (38 mins), Robinson for Francis (90 mins).
ST Patrick's Athletic: S Kelly; Burke, Maguire, S McGuinness, K Doyle; Croly, Griffin, Mbabazi, Russell; McCarthy, L Kelly. Subs: Osam for Mbabazi (30 mins), Quinn for L Kelly (90 mins.).
Referee: R O'Hanlon (Waterford).