The Bermuda cap, a £1.3million buy from Huddersfield's neighbours Bradford on Friday, hooked in the winner from a tight angle to earn a 1-0 win.
It came in the 90th minute after Millwall, who have now lost five of their last six games, failed to clear a corner.
Wells arrived as a second-half substitute to add some pep to an otherwise lacklustre attack and, before his late heroics, Millwall striker Scott McDonald had gone closest to breaking the deadlock in front of new Lions boss Ian Holloway.
McDonald, who had a loan spell at Huddersfield 11 years ago, hit the post from the edge of the box just before half-time. Richard Chaplow retrieved the ball and crossed for Steve Morison, whose header was well saved by keeper Alex Smithies.
The Lions had lost four of their last five matches before Holloway took over from Steve Lomas, who was sacked on Boxing Day.
In front of the well-travelled boss, Huddersfield started brightly but nearly gifted Millwall two goals, first when Smithies and Adam Clayton got in a muddle on 11 minutes; Clayton recovered to make a good tackle on Lee Martin as the midfielder was about to shoot inside the box.
Next came a poor backpass on 21 minutes from Oliver Norwood which let in Morison, with Smithies parrying his effort at the near post.
Opposite number David Forde made two parries of his own in a first half which Huddersfield dominated but rarely threatened in.
First Tommy Smith turned a cleared Clayton free-kick back into the box for Danny Ward to knock down, with Martin Paterson drawing a fine block from Forde.
That was on 31 minutes and soon after Paterson warmed Forde's palms again with a shot from Clayton's pass. This time the ball fell to Ward, who contrived to miss an open goal from about 12 yards with a woeful side-footed effort that drifted well wide.
Ward was substituted in a double change on 56 minutes that saw Wells enter the fray with Duane Holmes.
Wells joined the Terriers on an emergency loan on Friday after his soon-to-be-permanent transfer was not completed before the cut off point for this game, but regardless of his status, he did what he was brought in to do.
The Lions had shipped 49 goals, the worst tally in the league before this match, but Huddersfield could not find a way through until right at the end when Wells made it 50.
The former Carlisle man showed just why Huddersfield invested so much money in him when he made good of a hopeful long ball from Clayton and beat Forde from 10 yards.