A goal down to Kieran Lee’s fine header, Bournemouth looked to have pulled off a memorable comeback as Matt Ritchie crossed for Yann Kermorgant and then drilled home a stunning long-range effort himself either side of Simon Francis’ red card.
And the home fans, who had seen Middlesbrough overtake them with victory on Friday night, were counting down the seconds to a vital victory in the battle for promotion when Harry Arter fouled substitute Atdhe Nuhiu inside the box.
Chris Maguire stepped up and found the bottom corner to stun the sold-out Dean Court crowd.
The Cherries had endured an out-of-sorts opening 45 minutes that began with goalkeeper Artur Boruc having to pull off a magnificent block to deny Lee the opener.
The visitors, buoyed by their midweek win over Brentford, continued to look the brighter and it was no surprise when they broke the deadlock in the 36th minute. Lewis Buxton swung over a deep inviting cross from the right flank and Lee rose superbly to head into the far corner.
That was just the second time the Cherries had fallen behind in the league on home soil this season and they were stung into life with Arter forcing Chris Kirkland into a fingertip save from a long-range thumping effort.
The Dean Court faithful were then incensed that they were not awarded a penalty when Kamil Zayette tackled the rampaging figure of Andrew Surman just as he looked set to pull the trigger on the right-hand side of the Bournemouth box.
Half chances came and went either side of the break for Tommy Elphick and then Kermorgant as the Cherries struggled to replicate the free-flowing football they have shown off so often this season.
As the game reached the hour mark, Eddie Howe’s side were a lick of paint from going two down. A lovely curling right-footed free-kick from Maguire rattled Boruc’s right-hand post and fell kindly for Caolan Lavery who could only slice his first-time effort over the bar.
At the other end Callum Wilson felt he should have been awarded a spot-kick in the 65th minute. Having rounded Kirkland the former Coventry striker looked to have been fouled by Buxton but referee Paul Tierney disagreed.
Cardiff loanee Kenwyne Jones had been sent on for his aerial presence but it was fellow forward Kermorgant who nodded the home side level four minutes later, superbly meeting Ritchie’s cross with a near-post header which left Kirkland rooted to the spot.
Just as Bournemouth began to up the ante as the game edged towards the final 10 minutes there was to be another twist, right-back Francis picking up a second yellow for a clumsy foul on Maguire in the 79th minute.
When Howe withdrew Kermorgant for defender Elliott Ward to shore up his defence it looked to have been the wrong call when Surman was bundled down just outside the box and their free-kick expert was sat on the bench.
But Surman rolled the set-piece onto Ritchie’s left foot and he sent a stunning 25-yard rocket right into the top corner of Kirkland’s goal to spark wild celebrations amongst the 10 men.
Wednesday were not to be denied, though, and after Lavery missed a gilt-edged chance at the back-post they provided their vocal travelling support with something to sing about on the long journey home in the fifth minute of added time.