Mooy’s well-weighted 75th minute corner provided the assist for Elias Kachunga to make it 2-2 before Tommy Smith’s injury-time winner.

The Australian played a part in the winner, with his pressing forcing a turnover which led to the goal.

With top two Newcastle and Brighton both drawing in midweek, the result means third-placed Huddersfield closes the gap to four points for automatic promotion with 15 games to play.

Mooy had an industrious game, as always, looking to dictate play in midfield, while testing the Rotherham keeper from time to time.

With his side trailing 1-0, Mooy drove forward and forced a desperate clearance from a cut-back, while he also had an effort miss out.

At 2-2, Mooy searched for the winner with 25-yard strike fizzing over the bar.

Elsewhere, Bailey Wright put in a full shift as struggling Bristol City lost 2-1 at Leeds United.

Mile Jedinak was absent with injury as Aston Villa lost 3-1 at home to Barnsley.

Callum Elder started and played 55 minutes for Barnsley, while Ryan Williams was an 85th minute sub.