Thomas, borrowed by Pompey for a month, swept home a half-cleared corner in the 88th minute as Scunthorpe failed to hold on to their early lead.
Leon Clarke scored from close range for his fifth goal in succession since arriving from Charlton on loan in the sixth minute.
But Portsmouth were level in the 12th when defender Gabor Gyepes made the most of a mistake by goalkeeper Sam Slocombe.
Slocombe limped off after 23 minutes to be replaced by James Severn, who had been on nine minutes when he saved a penalty.
Lively Thomas was brought down by Niall Canavan but Severn blocked Brian Howard's spot kick.
Izale McLeod hit the bar in the first half and again in injury time as Portsmouth held on to Thomas's goal to record their first home league win.