Derry City moved back into third place in the League of Ireland table after coming from behind twice to beat Longford Town at Strokestown Road.
Dave O'Sullivan put Longford ahead on 12 minutes and while Barry McNamee levelled on 38, O'Sullivan's penalty restored the home team's lead on 63.
Derry looked to be running out of ideas but two Rory Patterson goals in two minutes turned the game on its head.
Patterson's equaliser came on 77 before he hit the winner two minutes later.
With three matches left, Derry are now two points ahead of Shamrock Rovers who were beaten by Bohemians on Friday night.
The defeat keeps Longford six points adrift at the foot of the table and looking likely relegation candidates.
Derry went into the game aiming to bounce back from the disappointment of Tuesday's FAI Cup semi-final replay defeat by Dundalk at the Brandywell.
However, Longford looked the more fired up side early on and great work by Don Cowan set up O'Sullivan's 12th-minute opener.
Derry regrouped to produce the more composed play and were deservedly on terms as McNamee hammered to the net on 38 after the Longford defence had failed to clear a Ronan Curtis cross.
Great defending by Longford's Conor Powell prevented Curtis for putting Derry ahead immediately after the resumption but the home team were back in the lead on 63 minutes as O'Sullivan held his nerve after Niclas Vemmelund had brought down Kaleem Simon in the penalty area.
Derry struggled to regroup from going behind for a second time but somewhat against the run of play, Patterson levelled on 77 after Yann M'Vita had failed to clear a cross.
Two minutes later, Patterson delivered again for Derry as he blasted home following a great pass from substitute Josh Daniels.