McGregor was sent off for kicking Marc McNulty on his back after clearing the ball out of his hands.
Referee Bobby Madden booked McNulty and awarded Rangers a free-kick as the Hibs striker maintained his innocence.
The hosts saw out a dramatic finale without any major scare and took all three points courtesy of Jermain Defoe’s 42nd-minute goal.
Defoe showed his renowned sharpness in the box to net his third goal in five games after being preferred to the returning Alfredo Morelos, who came close on several occasions after coming on as a late substitute on his return from a four-match ban.
Hibernian lacked a cutting edge as they suffered a first Ladbrokes Premiership defeat under Paul Heckingbottom, 11 league games into his reign, and saw their slim hopes of a Europa League place disappear in the process.
Ryan Gauld made his first start for three months after a hamstring injury and the former Dundee United player lined up in an attack-minded midfield three behind McNulty.
Defoe threatened to get in behind several times in the opening stages but Hibs were also getting forward and Gauld flashed a header wide.
The former England striker got his first real opening in the 19th minute when James Tavernier’s pass sent him through but he dragged his shot wide.
Ryan Kent shot straight at Ofir Marciano after Hibs lost the ball midway inside their half and Defoe passed up another chance when he could not react quickly enough as the Hibs goalkeeper spilled Ryan Jack’s low drive.
A forward run from Steven Davis finally broke the visitors’ resistance. Jack found him in space on the left edge of the box and the Northern Ireland midfielder delivered a first-time pass which Defoe swept home from eight yards after getting ahead of Lewis Stevenson, who appealed in vain for offside.