Matty Fryatt's quick-fire double early in the second half had given Nigel Pearson's men a comfortable lead at the Galpharm Stadium, but strikes from Gary Roberts and Liam Dickinson saw the Terriers draw level - only for Dyer to net the winner in stoppage time.
Town goalkeeper Matt Glennon denied Fryatt twice inside two minutes with good saves but the visitors made the perfect start to the second half when they eventually went ahead after 50 minutes. Nicky Adams went on a surging run down the right side and fed Fryatt who finished neatly from the middle of the penalty area.
Fryatt doubled his tally 15 minutes later when Jim Goodwin handled in the area and the former Walsall striker converted the spot-kick into the bottom-left corner.
Huddersfield got back in to the match after 70 minutes when Roberts fired in to the bottom corner from the edge of the area and they levelled eight minutes later when Dickinson headed home Goodwin's cross from six yards out.
Leicester were not going to be denied though and Dyer's 91st minute turn and shot looped over Glennon and in to the goal.