Greenacre headed his 12th of the season from a cross by substitute Calvin Zola.
Up to that point Cheltenham Town looked like posting a fourth successive win, but they stretched their unbeaten record to six games to boost hopes of avoiding the relegation zone.
The visitors dominated the opening period and built up a two-goal lead. Keith Lowe headed them in front from a John Melligan cross following a 17th minute corner.
They doubled their lead after 26 minutes. Kayode Odejayi fastened on to a low pass from what looked an offside position and neatly lobbed advancing keeper Gavin Ward.
The visitors could easily have had more first-half goals. Odejayi was wide when through in the sixth minute and in the 36th minute he saw a shot blocked by Ward.
Tranmere huffed and puffed to little advantage, but they were a different side after the break.
Chris Shuker, who was a constant thorn in the visiting defence, put them back in with a chance in the 49th minute. He worked his way to the corner of the box before putting a fine right-foot shot out of the reach of Shane Higgs.
But as the Merseysiders put the emphasis on attack they left themselves somewhat open at the back. Adam Connolly lobbed onto the top of the bar after 58 minutes and six minutes later Melligan saw a header from a Craig Armstrong cross turned onto the bar by Ward.
Steve Davies and Zola joined the action for Tranmere. Gareth Taylor headed just over and Shane Sherriff was wide from 35 yards, before Greenacre produced the face-saver in injury time as heavy rain poured down.
Shuker was the star man for Tranmere. Odejayi and Melligan were excellent for Cheltenham and there was also some good defensive work from Shane Duff and Michael Townsend.