Gayle's late header ensured Peterborough extended their unbeaten run to eight league matches.
The 22-year-old striker rose to head home Lee Tomlin's corner in the 86th minute to register his 19th goal of the season, but the point was not enough to lift Posh out of the bottom three.
Neil Danns slammed home the game's opening goal when following up a rebound just before half-time and, after Tomlin had equalised for the visitors five minutes into the second period, young defender Murray Wallace headed home his first goal in English football as Huddersfield regained the lead.
The point was enough to lift the Yorkshire side out of the relegation zone, but they are one of three clubs who are only a point better off than the two clubs in the bottom three below them, Blackburn and Peterborough.
Both sides found it difficult to penetrate the opposition's rearguard during the first period and, although it was Peterborough who hogged possession, Huddersfield went closest again through Woods' wayward cross-shot from outside the area.
Huddersfield went ahead just before the interval as a direct result of an Oliver Norwood blockbuster from 30 yards. Posh goalkeeper Robert Olejnik did well to keep out Norwood's initial drive, but when the ball spilled on the edge of the six-yard box, Danns pounced to lash it into the roof of the net.
Two minutes after the restart Sean Scannell tested Olejnik again with a left-footed shot from just outside the area that the Posh keeper chose to punch clear.
But Peterborough were back on level terms soon after. Nathaniel Mendez-Laing made space on the right side of the area and pulled the ball back for Tomlin to fire past helpless Town keeper Alex Smithies from 12 yards.
But Huddersfield struck the next significant blow in the 69th minute. Norwood was instrumental again, his cross from the left picking out defender Wallace, who powered his header beyond Olejnik from six yards.
But with four minutes remaining Tomlin whipped in a corner from the right and Gayle's downward header at the far post denied Huddersfield two points in their fight for survival.