Hugo Rodallega's emphatic late header consigned Stoke to a third successive defeat as Wigan edged a fraught contest to retain their Premier League status.
With 12 minutes remaining of an excruciatingly tense encounter, Rodallega found the top corner from Charles N'Zogbia's far-post cross.
Stoke had earlier dominated, with Latics keeper Ali Al Habsi obliged to pull off a string of impressive saves.
But Wigan's second-half improvement secured safety for a seventh season.
On an afternoon of exhausting uncertainty, Wigan knew from the outset that victory would not guarantee survival, just as defeat would not necessarily consign them to the Championship.
But the visitors overcame a desperately nervous start before gradually edging their way to safety in the face of stern resistance from Stoke and an incessant wave of twists and turns elsewhere.
When the dust finally settled, Wigan manager Roberto Martinez emerged drenched in champagne. After masterminding an unlikely climb to safety, he deserved the acclaim.
This was the first time in two years that the Spaniard had overseen back-to-back league wins, and it was not a bad time to do so.
As for Stoke, a third defeat in nine days may have ensured their campaign ended with something of a whimper but, however disappointing the denouement, it has been a season of outstanding progress for the Potters.
A first FA Cup final appearance in the club's 148-year history and a mid-table finish in a freakishly compact Premier League speaks volumes for the shrewd stewardship of manager Tony Pulis.
In the end, victory was a luxury rather than a necessity for Wigan. Defeats for Birmingham and Blackpool meant it was they who will be playing Championship football next season.
It was impossible to detect from Martinez's smiling countenance the inner tension he must have been feeling as he disembarked from the team coach, but the drawn features of the players who followed behind him told a different story.
As kick-off neared, Al Habsi prayed and his manager paced the touchline, his brow now contorted under the weight of the occasion; it was that kind of day.
Their apprehension looked justified when Antolin Alcaraz almost sold Al Habsi short with a weak back-pass within moments of the first whistle.
With Kenwyne Jones looming, the Wigan keeper rushed out to spare his skipper's blushes, a moment that proved the cue for a sustained barrage of Stoke pressure.
Predictably, Rory Delap's trademark long throws were a particular source of consternation for the visitors.
Hearts were in Wigan mouths when Jones headed goalwards from one such missile, but Jonathan Walters, who was clearly offside, applied a needless touch from a couple of yards out and was correctly penalised.
The linesman's flag did nothing to deter the vociferous home support. "We're sending you down," they crowed. And as Al Habsi beat away efforts from Jones and Jermaine Pennant, and Emmerson Boyce hacked another Jones effort off the line, it looked like they just might.
By half-time, nothing had changed. With Blackpool and Birmingham level at Old Trafford and White Hart Lane respectively, and Wolves trailing 3-0 at home to Blackburn, Wigan were one of four teams on 40 points.
Yet they remained where they had been from the outset - second from bottom, albeit only on goal difference.
The grim scramble for survival soon began to assume a different complexion, however.
Wigan started the second half with the air of a team transformed. For the first time, an away goal looked possible. Some 130 miles to the south, Roman Pavlyuchenko put Spurs ahead against Birmingham. The visitors were up to 18th, behind Wolves only on goals scored.
Hope stirred among the blue-and-white pocket of away fans. N'Zogbia blasted over and Pennant appeared to impede Rodallega as he cut in from the left. Referee Andre Marriner ruled it was not a penalty.
Minutes later, Wigan survived a similar claim as Alcaraz climbed all over Jones. Unperturbed, Wigan pressed on. Conor Sammon, the hero against West Ham last weekend, forced a first save of the afternoon from Stoke keeper Asmir Begovic before being replaced by Tom Cleverley, who almost immediately did likewise.
Then, just after 1730 BST, came the news Wigan had been waiting for. Manchester United had gone 3-2 up against Blackpool at Old Trafford. If results stayed the same, Wigan were safe.
The jubilation of the travelling support turned to euphoria when Rodallega rose in the six-yard box to head home N'Zogbia's left-wing cross 13 minutes from time.
Visiting nerves grew increasingly taut as the allotted five minutes of added time stretched into six, but in the end there was to be no denying a Wigan side who looked dead and buried when two goals down at half-time a week ago.