A dramatic Steve Feeney goal in the fifth minute of injury time at Ferney Park helped Ballinamallard United retain their Irish Premiership status.
The goal earned his side a 3-3 draw and a 5-4 triumph on aggregate.
Institute led three times on the night with goals from Jamie Dunne, Gareth Brown and Shane McGinty.
The Mallards struck back each time with replies from Emmett Friars, Cathal Beacom and finally Feeney, in new boss Gavin Dykes's first game in charge.
Dykes was in the dugout as former boss Whitey Anderson served a suspension.
The Mallards won the first leg 2-1 at Drumahoe on 6 May but the sides had to wait seven weeks to play their second leg because of a wrangle over a ban served by Carrick Rangers manager Gary Haveron.
With Institute leading on away goals and the Mallards down to 10 men following the dismissal of Liam McMenamin in the 90th minute, the Fermanagh side's four-year stay in the top flight looked to be coming to an end.
Dunne drilled a low effort beyond home keeper Alvin Rouse in the 17th minute for the opener, before Friars headed home the leveller from a Jason McCartney free-kick.
Institute regained the lead in the 27th minute when an excellent low cross from the right was steered home by Gareth Brown.
The hosts were awarded a penalty on the hour when Johnny Lafferty was taken down in the box by Stephen O'Donnell and Cathal Beacom netted emphatically from the spot.
Institute responded in some style as Shane McGinty unleashed an unstoppable effort that flew past Rouse.