Rangers defied UEFA to go ahead with pre-match plans to sing God Save The King before the game following the death of Queen Elizabeth II.
The emotional atmosphere lifted Rangers early on and Alfredo Morelos skewed a close-range header wide. Piotr Zielinski then cracked the post at the other end before Scott Arfield drew a fine save out of Alex Meret.
Yet Rangers' good work in the first half was undone by a chaotic second period, in which 40-year-old McGregor played a starring role.
James Sands was shown a second yellow card for bringing down Giovanni Simeone as he broke into the box. Zielinski's subsequent penalty was brilliantly turned away by McGregor but only as far as Matteo Politano, who finished from a tight angle.
However, Politano was deemed to have encroached before the penalty was taken and McGregor produced heroics from the retake to thwart the Poland international.
McGregor, though, could not deny Napoli a third time after Borna Barisic was deemed to have handled in the area, Politano's penalty squeaking under his hand and into the bottom-right corner.
Giacomo Raspadori fired home a late second after a one-two with fellow substitute Mathias Olivera and Tanguy Ndombele added further gloss to the scoreline before Rangers had a penalty overturned by VAR as Napoli moved three points at the top of Group A.