With the clock running down, visiting goalkeeper Matthew Turner was unable to claim a Leo Smith cross, and when it fell to Hudson, the defender drilled home to seal an eighth win from nine league games for the table-toppers this season.
Haverfordwest took a 12th minute lead at Park Hall as Jack Wilson ran on to a pass from Corey Shephard to beat advancing goalkeeper Paul Harrison.
TNS pulled level on the half-hour mark, with Ben Clark, who scored a late equaliser for Saints in their previous match at Aberystwyth Town, heading home a Ryan Harrington cross.
The visitors regained the lead seven minutes into the second half via a penalty from Danny Williams, but Saints showed character and were quickly back on level terms within five minutes when Chris Marriott’s free kick was turned into his own net by Sean Pemberton.
Then came the late drama with Hudson emerging as the TNS match winner.
“I think we got out of jail,” said TNS manager Scott Ruscoe. “We were lucky there. I didn’t think we played particularly well in spells in either half. We just did enough.
“They came here with energy, with a bit of passion, and nearly got a very good result.
“But, on the other hand, in our first nine games of the season, to be five points clear and to win eight and draw one is very encouraging - but, yes, today we weren’t at our best.”
TNS: Harrison, Hudson, Astles, Marriott, Boateng (Draper 60), Clark, Smith, Harrington (Spender 86), Robles, Ebbe (Rees 86), Cieslewicz. Subs not used: Lyon, Bailey, Cornish, Williams.