A Pascal Vaudequin header 12 minutes from time gave Shamrock Rovers full reward for their part in what was a thrilling encounter at Tolka Park.
The Frenchman found himself totally free inside the Shelbourne penalty area six minutes after his introduction as a substitute to head past Steve Williams from Tony Grant's cross.
In a right rollercoaster of a match, the visitors hearts then skipped a beat in injury time as Jonathan Prizeman's right foot drive came back off a post. It was that sort of game as Rovers stubbornly refused to allow Shelbourne earn a fifth successive win. Having weathered an early Rovers storm when Damien Richardon's side wasted two good chances from Brian Byrne and Sean Francis inside the opening four minutes, Shelbourne struck for a delightful lead goal on eight minutes.
Pat Fenlon found Dessie Baker down the right. And though James Keddy mishit Baker's low cross, the ball ran invitingly for Stephen Geoghegan whose predatory instinct took over as he picked his spot.
We had chances at both ends before Rovers were level on 22 minutes. Williams' will be unhappy as he was beaten at his near post from a Marc Kenny free-kick after Tony Grant had been fouled 20 yards out. But in a game which you literally couldn't take your eyes off Rovers found themselves behind again from a candidate for goal of the season on 36 minutes.
Richie Baker elected to pick out Fenlon rather than cross. And the Shelbourne midfielder took a touch to beat Robbie Horgan with a terrific left foot strike into the bottom corner from all of 30 yards.
Shelbourne: Williams; Heary, Scully, McCarthy, Hutchison; R. Baker, Byrne, Fenlon, Keddy; D. Baker, S. Geoghegan. Subs: Prizeman for Heary (85 mins.).
Shamrock Rovers: Horgan; Smith, Palmer, Cronin, Dunne; Kenny, Colwell, Tracey, Byrne; Francis, Grant. Subs: Woods and Vaudequin for Byrne and Tracey (both 70 mins.), Cousins for Francis (72 mins.).
Referee: H Byrne (Dublin).