 Mark Farren scored Derry's winning goal |
A 61st minute goal by Mark Farren saw Derry close to within three points of leaders Shelbourne at the top of the table with two games still to play. David Forde saved a Michael Foley penalty on 12 minutes.
Sub Killian Brennan and Pat McCourt combined to set up Farren for the winner, the striker beating Barry Ryan.
St Pat's put on the pressure late on and Colm Foley had an effort ruled out for offside but City held on while Shelbourne went down 1-0 at Cork City.
Afterwards Derry boss Stephen Kenny said it was "great to bounce back with a brilliant win" after the midweek defeat by Drogheda.
"A win of this magnitude keeps it alive for us as we really needed a win to stay anywhere near in contention," he added.
The Candystripes will lock horns with the Dublin team again in the FAI Cup final on Sunday 3 December.