Bohemians manager Keith Long spoke this week about his side needing the mid-season break but he may be revising that given the momentum that his side would have gained from what was a thrilling Dublin derby victory.
Bohs were second best for an hour last night and Shamrock Rovers, who had led since the ninth minute, were stunned late on by three goals in 13 minutes.
Long introduced Dean Kelly from the bench with 17 minutes remaining and the striker's two goals ensured that Bohs bounced back from Tuesday's defeat to St. Pat's.
The Gypsies welcomed Dave Mulcahy and Anto Flood back into the starting XI and their freshness was very much needed in a week when their side played three of the league's top four sides.
Bohs will go into the two-week break buoyed by what is a massive win over their fiercest rivals who saw their 16-game unbeaten streak dashed in front of 3,385 raucous supporters at Dalymount Park.
In the absence of the suspended Mikey Drennan, Pat Fenlon handed a first start to 19-year-old Gareth McCaffrey and playing as the lone striker, he caused plenty of problems throughout.
The goal that Bohs conceded will have infuriated Long as it was one of the smallest players on the pitch, Kieran Marty Waters, who headed home unchallenged. McPhail swung in a free-kick from wide on the right and Waters was left unmarked to head passed a helpless Dean Delany.
The visitors missed a gilt-edged chance to double their lead four minutes later and it came from another set piece.
Gary McCabe's corner found the unmarked Conor Kenna but the defender was unable to keep his header on target as the groans among the home supporters grew louder.
Those frustrations might have been eased had Ismahil Akinade kept a header of his own on target before Anto Murphy couldn't stretch far enough to poke home Lorcan Fitzgerald's free-kick.
Akinade thought he was in on goal shortly after the restart but the referee adjudged that he fouled Craig Hyland which incensed the home crowd and McCaffrey almost heaped further woe on them.
McPhail played the young striker through but he was denied by Delany who got down well to save.
Bohs thought they had pulled level but the referee ruled out Murphy's goal after he spotted that a Rovers defender was pushed into Hyland before the 'keeper spilled the ball.
There was no doubting Derek Prendergast's 77th-minute equaliser however. He powered home his second goal in two games as the home crowd began to believe there was more than a point on offer.
And so there was. With six minutes remaining, Kelly's headed goal sparked pandemonium among the Bohs supporters.
There was still time left for Kelly to rub salt in Rovers' wounds when deep into stoppage time, he was on hand to finish off excellent play by Akinade.
Rovers' unbeaten run is over but for Bohs, six points from a possible nine against three of the league's top teams isn't a bad week's work.
Bohemians - Delany; Murphy, Mulcahy, Prendergast, Fitzgerald; Hyland (Kelly 73), Lopes (c); Buckley (Dillon 85), Evans, Moore; Akinade.
Shamrock Rovers - Hyland; Madden, Kenna (c) (Clancy h/t), Webster, Byrne; McCabe, Cregg, McPhail, Miele (R Brennan 81), Waters; McCaffrey (G Brennan 71).
Ref - D McKeon (Dublin).