Terriers striker Wells – who has watched from the bench for the last two games – scored from the penalty spot before heading home from close range to cap an amazing fightback from the visitors.
Ipswich centre-backs Tommy Smith and Christophe Berra had put the home side ahead.
Before the second half drama, Grant Holt, so often a thorn in Ipswich’s side when leading the line at rivals Norwich, should have given the Terriers a 13th minute lead.
Jacob Butterfield broke clear before releasing Holt but he poked a shot wide of the far post when he should have made Dean Gerken work.
And the striker was made to pay for the miss after 20 minutes when Ipswich took the lead with their first effort on target.
A succession of corners ended with Teddy Bishop’s flag kick finding the head of Tommy Smith who nodded in at the near post.
The lively Wells went close in the 32nd minute when Paul Dixon’s through ball somehow made its way through to the Huddersfield striker.
His instant shot was blocked by Gerken and the rebound came at him too quickly as he headed it over.
Huddersfield had responded well, but almost fell two behind when Bishop’s free kick went all the way through to Smith who deflected the ball onto the post before Alex Smithies just about gathered the rebound.
Wells had Gerken scampering across his goal in injury time, when his audacious first-time volley from an acute angle was tipped around the post by the alert Ipswich keeper.
Ipswich doubled their advantage nine minutes after the restart when McGoldrick controlled Jonathan Parr’s clip over the static away defence and the striker’s low cross was turned in by the unmarked Berra from close range.
Halfway through the second half, Terriers keeper Smithies was called upon to expertly use his head as McGoldrick beared down on goal.
Out of nothing, Huddersfield got themselves back into game following a hotly-disputed penalty.
A deep cross into the area saw Chambers and Holt go to ground and referee Richard Clark had no hesitation in pointing to the spot.
Wells made no mistake from 12 yards to grab a deserved goal before substitute Harry Bunn shot at Gerken’s legs as Huddersfield went for the equaliser.
Murphy drilled a shot just wide and then had a header which lacked power to trouble Smithies before Huddersfield equalised with eight minutes remaining.
Substitute Sean Scannell’s cross found Wells who headed home from the edge of the six-yard-box.