St Helens booked a Super League play-off clash at Warrington next Saturday after overcoming 12-man Wigan in a dramatic derby at the DW Stadium.
Tries from James Roby, Tommy Makinson, Andrew Dixon, Josh Jones and Jonny Lomax secured third place for Saints.
But the whole contest hinged on a disputed 16th-minute red card for Wigan forward Michael McIlorum for a late hit on Saints prop Anthony Laffranchi.
Thomas Leuluai, Pat Richards and Sam Tomkins claimed the Warriors' tries.
Richards also kicked all his three conversions, while Makinson landed three of his five.
Hooker McIlorum could now miss the start of the Warriors' play-off campaign through suspension, but coach Shaun Wane insisted that they will fight any threat to ban him following his controversial dismissal by referee James Child.
It was a first win over Wigan in four attempts for the St Helens caretaker management team of Mike Rush and Keiron Cunningham, as they keep the bench warm for Nathan Brown - and that put a dampener on the end-of-match celebrations when Wane's Warriors were presented with the League Leaders' Shield.
Since Rush and Cunningham took charge in late March, Saints have only suffered five defeats - and the first three of them were all against the Cherry and Whites.
After losing 28-10 at home to Wigan on Good Friday, Saints were then beaten 18-4 at the DW Stadium in the Challenge Cup quarter-final a month later.
And Wigan again ran out winners, 42-16, when the two sides met again in an ill-tempered Magic Weekend encounter at the Etihad Stadium a fortnight after that.
Wigan will now expect to play fourth-placed Catalan Dragons next weekend, unless the French side slip up at Bradford on Saturday and fifth-placed Leeds then win at Huddersfield the following day.
Wigan took an early lead when fit-again scrum-half Leuluai sneaked through a gap, Richards' goal making it 6-0.
Four minutes later McIlorum was given his straight red for going in late and high on Laffranchi, but it took the visitors some time to make their man advantage count.
They finally seized control with two tries in six minutes from hooker Roby, who took a superb offload from Tony Puletua, and winger Makinson, who finished in the right corner after centre Michael Shenton had sucked in two defenders.
Makinson added both conversions, the second from the touchline, to make it 12-6 and that is how it stayed until Wigan drew level three minutes into the second half.
Skipper Sean O'Loughlin took over the dummy-half duties in the absence of McIlorum and his cut-out pass got Richards in at the corner.
With the experienced Jon Wilkin twice kicking out on the full, the game appeared to be heading battling Wigan's way until a handling error on 57 minutes by Tomkins 30 metres out from his own line.
Puleuta found himself in space and he powered through before getting the supporting Dixon over.
Having lost Lomax six minutes into the second half, the scrum-half'slate return proved crucial.
First, he took a return pass from the ever-dangerous Puletua before combining with Lance Hohaia to get centre Jones over.
Then, after Makinson had again failed with the conversion, Lomax sealed victory nine minutes from time from a Louie McCarthy-Scarsbrook offload.
Tomkins grabbed a last-minute consolation try but, by then, the Saints fans were the ones enjoying the party as they prepare to go in search of a seventh successive October trip to Old Trafford.
VIEW FROM THE DRESSING ROOM
Wigan coach Shaun Wane:
"I don't think the referee got it right. It looked like Micky Mac was committed. He's an important player and I want him playing for me next week. We'll go there and fight it if we have to. We feel we have a strong case.
"Leaving your team-mates in a massive game against your arch rivals is like a suspension in itself. I don't mind the sending-off if they are consistent through the year.
"But I'll take it on the chin. And I'd rather talk about the positive aspects about how we dug deep and showed some character with 12 men.
"It would be nice to get Leeds after what they did to us in the Challenge Cup semi."
St Helens interim coach Mike Rush:
"It's always going to be talking point or a turning point. They had to work a bit harder but they are still a very good side. They still threw an awful lot at us and we had to defend really well.
"It's about building some momentum and ensuring we've got that mentality for play-off football because it is different.
"We had to start upping the ante and I think we got better but there is still got a bit to go yet.
"I'm very proud of the players but we're not going to get carried away. We've put a marker down that we are intent on getting to the Grand Final and winning it this time."
FRIDAY NIGHT'S LINE-UPS
Wigan: S Tomkins; Charnley, Goulding, Carmont, Richards; Finch, Leuluai; Fielden, McIlorum, Lima, Hansen, Hock, O'Loughlin.
Replacements: Mossop, Farrell, Dudson, Flower.
St Helens: Wellens; Makinson, Shenton, J Jones, Meli; Hohaia, Lomax; Perry, Roby, Laffranchi, Flanagan, Puletua, Wilkin.
Replacements: McCarthy-Scarsbrook, Greenwood, Clough, Dixon.
Referee: James Child (Dewsbury).