Porter completed his treble in the 78th minute, the exact time last year when the late skipper collapsed against Dundee United.
The goal heralded a show of remembrance from the Motherwell support for O’Donnell, whose former team-mates produced one of their best displays of the season at Fir Park.
Porter scored twice in a first half dominated by the hosts, whose win would have been more resounding had they not conceded goals to Ross Tokely and Adam Rooney in the closing stages of each half.
Motherwell made five changes following last weekend’s defeat at Hamilton, with key trio Stephen Craigan, David Clarkson and Stephen Hughes back from illness and injury, and Marc Fitzpatrick and Jim O’Brien recalled.
A five-match losing streak had taken them to the foot of the SPL alongside Hamilton, Falkirk and Inverness, who brought in Phil McGuire for the injured Ian Black following four consecutive defeats.
The Motherwell players formed a huddle before kick-off to remember O’Donnell, who collapsed with heart failure during the 5-3 win over United on December 29 last year.
The Fir Park pitch was heavily frosted, especially in the area in front of the South Stand where the undersoil heating failed ahead of the postponed game against Hearts earlier this month.
But Motherwell, who face a Scottish Premier League hearing over the postponement, took just eight minutes to score at that end – their first goal from open play since November 1.
Stevie Hammell curled in a cross from the right wing and Porter, who has been linked with a move to Nottingham Forest and Sheffield United, dived in between two defenders to head into the corner.
Porter soon headed over under pressure from a floating cross from Hughes and then forced Ryan Esson to dive to stop his low shot from 18 yards after running on to Hammell’s through-ball.
McGhee’s men seemed to have rediscovered their confidence as they swept forward with pace and precision, and they were unfortunate not to get a penalty from Charlie Richmond when Tokely bundled Hughes over from behind.
Grant Munro was booked for a cynical body-check on Clarkson, who soon shot just wide from 30 yards as the match continued to be played out almost entirely in the Inverness half.
Porter headed a second in the 39th minute, cleverly guiding Paul Quinn’s inviting cross into the far corner.
Graeme Smith made his first save when he comfortably held Don Cowie’s ambitious free-kick, but he was beaten in the 44th minute.
The Motherwell keeper looked like taking Dougie Imrie’s corner but Hughes headed the ball out of his reach and into the goalmouth, where Tokely nodded home from close range.
Hughes volleyed just wide from 20 yards as Motherwell tried to restore their advantage before the break.
Rooney replaced Imrie as Inverness put two men up front, and fellow striker Garry Wood shot a yard wide after Well team-mates Mark Reynolds and Maros Klimpl, who otherwise shone in midfield, collided on the edge of the box.
Clarkson had a great chance when a Hughes cross found him unmarked six yards out, but he skewed his header well over.
The home side had quickly settled back into a high-tempo passing game and again pushed Inverness back, but the visitors were showing greater ambition and purpose when they did break out.
Porter scored his seventh goal of the season right at the start of the 78th minute when he headed from close range after Hammell had whipped in a free-kick from the right.
It was the exact time in the game when O’Donnell had collapsed against United, and the Motherwell support rose to chant his name immediately after celebrating the goal.
Hammell slammed the ball into the side-netting after breaking down the left and Motherwell looked like seeing out the game until Craigan was penalised for leaning on substitute Andrew Barrowman inside the box.
Smith dived low to his right to brilliantly save Rooney’s injury-time penalty but the Irishman followed in to nod the ball over the line.