John O'Flynn ended his goal drought to move City up into second place, six points behind leaders Bohemians.
O'Flynn, who hadn't scored in five games, finally brought a dull game to life with the lead goal on 84 minutes.
Taken down by Willie Burke on the edge of the area, O'Flynn took the free kick himself and it deflected off the St. Pat's wall to beat Shay Kelly for his 13th goal of the season.
St. Pat's finished the match with ten men when winger Tony Bird was sent off for dissent two minutes from the end.
Colin Patrick O'Brien then added City's second goal deep into stoppage time with a solo effort.