Super sub Mark McKenzie produced a last gasp moment of glory to send Ayr to the promised land of the play offs.
The United Academy product stepped off the bench with United looking on the canvas after being hauled back to 1-1 and sitting in fifth place staring up at the end of season shootout.
But he remained the coolest man in the Highlands to slot home a cutback from fellow sub Daire O'Connor and send Ayr through.
On a night of incredible drama, Ayr secured their place as runners up and will now await the winners of Queen's Park against Partick Thistle.
Lee Bullen had made just the one change from the side which beat Raith last week with Ben Dempsey returning in place of Reece McAlear at the heart of midfield.
And United began brightly with chances to hit the front early doors.
Chris Maguire fired wide from the edge of the box in the opening minutes with Dipo Akinyemi screaming for a pass to his right.
Maguire twice went close before the half hour, while Mullin saw a free kick tipped over by Mark Ridgers as Ayr had much the better of the early exchanges.
But United's pressure would duly reap its rewards as they deservedly hit the front ten minutes before the break.
Maguire showed great composure to send Mullin through on goal and the midfielder applied a clinical finish to rifle beyond Ridgers.
Caley boss Billy Dodds made a double switch at the break to try and breathe new life into his side and they were a different proposition after the interval.
Frankie Musonda was required to clear off the line from sub Austin Samuels as the hosts flung bodies forward.
Bullen turned to his bench as Ayr came under increasing pressure, with Caley old boy McAlear replacing Sam Ashford and United going to five in midfield.
United were prepared to sit in and soak up pressure in their quest for the full time whistle but they were on the floor when Billy McKay teed up Nathan Shaw to fire home with eight minutes to go.
That looked to have killed Ayr's hopes before O'Connor and McKenzie stepped off the bench and combined for the moment of late magic.