Rovers' attempt to avoid a third straight league defeat suffered an early blow when Liam Palmer was sent off for a dangerous lunge in only the sixth minute.
Shrews debutant Porter pounced on an error from goalkeeper Owain Fon Williams to put the Shrews ahead soon after before Gayle headed in midway through the second half to clinch back-to-back wins on the road for the visitors.
Tranmere, who included midfielder Paul Corry on the bench following his last-minute loan move from Sheffield Wednesday, began the game in disastrous fashion when Palmer was shown a straight red card for a lunge on Shrewsbury left-back Joe Jacobson.
It went from bad to worse only four minutes later when goalkeeper Fon Williams fumbled a high ball and Porter, on loan from Sheffield United, pounced to fire the visitors ahead.
In the second half Porter missed his kick with the goal gaping before David McAllister shot over.
Fon Williams then made a fine save to deny Porter only for Shrewsbury to net from the resulting corner as Gayle nodded in with the goalkeeper stranded.