Motherwell took control after a slow start to the crunch Scottish Premier League game and substitute Darren Smith scrambled them into a deserved lead just after the hour mark.
Aberdeen soon levelled out of the blue through Sone Aluko but Porter finished off a slick move nine minutes from time to tighten Motherwell's stranglehold on third place.
Aberdeen though were raging after the final whistle, believing they were robbed of a goal when Graeme Smith pushed away a shot by Barry Nicholson, which the Dons staff were told had crossed the line.
Home boss Mark McGhee recalled Steven Hammell, Porter and David Clarkson as Simon Lappin, Ross McCormack and Keith Lasley dropped to the bench following Wednesday's 1-0 defeat at Rangers.
Aberdeen were looking for their third successive win to move level on points with Motherwell in the race for Europe, but their UEFA Cup hopes are now over.
Jimmy Calderwood recalled Josh Walker while both Darren Mackie and Alan Maybury returned from injury, with Jeffrey De Visscher and Chris Maguire dropping to the bench and Derek Young missing out.
After Dundee United's lunchtime defeat by Rangers, the home side knew victory coupled with a Celtic win over Hibernian tomorrow would put them in the UEFA Cup for the first time in 13 years.
A bumper crowd, enticed by £5 admission prices, held a minute's applause for former Fir Park greats Charlie Aitken and Matt Thomson, who both died in recent months.
Motherwell carved out the first chance in the 13th minute following good link-up play by Clarkson and Porter.
Clarkson headed on a flighted ball from Mark Reynolds and confidently controlled Porter's instant return pass, but the striker volleyed over from 12 yards with his left foot.
Aberdeen were seeing plenty of the ball though and Motherwell goalkeeper Smith had to look lively to smother at the feet of Walker following a quick break through the middle.
The Dons suffered a blow in the 18th minute when centre-back Andrew Considine limped off. Calderwood, already missing the suspended Zander Diamond, brought on Dave Bus to play alongside Scott Severin and Karim Touzani in a back three.
The visitors continued to look the more dangerous team and Walker had a low drive comfortably saved before Mackie's ball across the face of goal found no takers.
Motherwell created the best chance of the half following their first sustained spell of possession, when Porter rose to head a Stephen Hughes cross eight yards out, but Bus did enough to divert the ball behind.
McGarry failed to maintain the pressure as he sliced the corner straight out of play but the hosts continued to dominate territory following their slow start.
However, their passing on the uneven surface lacked the guile displayed earlier in the season and the only further meaningful first-half effort came when Hammell's 25-yard free-kick was tipped over by the well-placed Jamie Langfield.
McGhee made a positive change at half-time when he brought on winger Darren Smith for Marc Fitzpatrick. His players matched his mood by putting Aberdeen under pressure from a series of set-pieces.
Porter had a chance to set up Clarkson after beating the offside trap when Reynolds returned a clearance but he overhit his cross.
Clarkson and Porter both headed over after corners by Hammell as Motherwell continued to stretch Aberdeen by passing the ball around with conviction.
And they were rewarded in the 61st minute when substitute Smith stabbed home the opener from six yards.
Porter headed down a dangerous cross by Hughes and the teenager poked the ball into the bottom corner at the second attempt.
However, Calderwood made his own inspired substitution as Aluko levelled with an impressive volley in the 68th minute, moments after coming on.
Mackie crossed to the far post and the teenager fired a powerful left-footed volley into the far corner in Aberdeen's first attack of the half.
Calderwood's decision to take off Walker had met with boos from the away fans, but Aluko almost carved out a second before his whipped cross from the byline was headed away by Reynolds.
Motherwell appeared to be in shock and Smith came to their rescue when he raced across goal to claw away Nicholson's hooked effort after Bob Malcolm had failed to spot the danger from Stuart Duff's cross.
It was a save which would later be questioned by the Dons staff and players, with images of the incident apparently showing the ball was over the line.
The Lanarkshire side soon came back into it though and McCormack fired wide of the near post via a deflection after Clarkson's touch had sent him in from the left flank.
The game opened up completely as both sides chased the victory and Porter struck the winner in the 81st minute as Motherwell cut Aberdeen apart.
Clarkson sent Hughes racing down the right channel and his square ball was steered high into the net by the unmarked Porter.
Well lost McCormack to injury with Lappin taking his place but they kept their discipline as Aberdeen piled men forward.
And they survived a huge scare in injury-time when Dons sub Maguire curled a 20-yard free-kick off the bar, with the rebound falling kindly for the hosts.