Ulster produced a famous 22-11 victory to reach the knockout stages and send Sale Sharks out of the Heineken Champions Cup at Kingspan Stadium.
Rob Lyttle scored a well-taken try as Ulster led 8-6 at the break.
England's Ben Curry put Sale ahead but Rob Herring hit back for Ulster.
While Ulster fell to last-gasp defeats in their three previous matches, Dan McFarland's side rallied in the closing stages and Duane Vermeulen scored under the posts to secure the win.
Ulster sit eighth in Pool B, with the top eight teams progressing, and look set to face Irish rivals Leinster in Dublin in the last 16 unless Montpellier fall to a heavy defeat by London Irish on Sunday.
Sale are set to play Challenge Cup rugby after falling to 10th in Pool B with the defeat.
The final pool game was set to be a winner-takes-all showdown with Sale ninth heading into the game, one place ahead of winless Ulster.
Ulster edge first half
The swirling wind around south Belfast caused havoc in the first half as Ulster played into a stiff breeze and Sale, who won the reverse fixture 39-0, started the better side and got an early reward when Robert du Preez knocked over a penalty after the hosts were penalised at the breakdown.
However, Ulster grew into the half and worked their way deep into the Sale 22. Each metre gained towards the try-line was met by a growing roar from the vocal home support, and they were nearly rewarded when Nathan Doak made a half-break and was brought down a metre out.
Another handling error, one of many from Ulster in the first half, saw the move collapse but referee Pierre Brousset came back for the penalty and prop Bevan Rodd was sent to the bin.
The tap and go penalty was wasted as Sale snatched the ball, but Ulster rallied and came again, which resulted in Lyttle collecting the bouncing ball and the winger stretched out to touch down and nudge Ulster into the lead.
Doak missed the conversion in tricky conditions, but Sale fly-half du Preez made no mistake from the tee and put the Sharks into the lead with a penalty midway through the half.
However, it was Ulster who went into the break in the lead when Doak kicked his first points with a well-struck penalty.
Herring & Vermeulen spark wild celebrations
Sale pressed early in the second half and Doak was sent to the bin for a deliberate knock-on but some stern Ulster defence kept the Sharks out.
However, the English Premiership side capitalised when Ewan Ashman broke away from a line-out and set up Curry, who powered over in the corner. Du Preez, in a similar position to Doak's missed conversion, could not convert from the tee.
Ulster piled forward and looked to have got over the line but some ferocious Sale defence saw the visitors awarded the dropout following a lengthy delay for a check with the TMO.
Moments later a near carbon copy happened as a pile of yellow shirts drove over the line but Brousset adjudged the Sale defence held firm once more, much to the frustration of the home support.
The game opened up as Ulster pushed for the much-needed point, with John Cooney and Michael Lowry almost combining to get over.
However, Ulster won the penalty and got the well-deserved try when Herring broke away from the maul to fly over with 15 minutes to play, and Cooney converted to put further daylight between the sides.
There was tension around the stadium, with fresh memories from Ulster's three previous heartreaking last-gasp defeats, but the hosts came again and South Africa's World Cup winner Vermeulen powered over under the posts with minutes to play, and Cooney's conversion put the game beyond doubt.
Ulster: Lowry; Lyttle, Hume, McCloskey, Stockdale; Burns, Doak; Warwick, Stewart, Toomaga-Allen; O'Connor (capt), Carter; Sheridan, Timoney, Vermeulen.
Replacements: Herring, O'Sullivan, O'Toole, Treadwell, Murphy, Cooney, Madigan Moxham.
Sale: Carpenter; O'Flaherty, S James, Tuilagi, Reed; R Du Preez, Warr; Rodd, Ashman, Harper; Beaumont, Hill; Ross, B Curry (capt), JL Du Preez
Replacements: Taylor, Harrison, Jones, Birch, Dugdale, Quirke, Curtis, Roebuck.