Ishmael Miller grabbed his first goal of the season to seal Huddersfield Town’s first home win under David Wagner.
The big striker’s well-taken 73rd-minute minute strike came in the nick of time, because Rotherham United were threatening to cancel out the first-half lead supplied by Mustapha Carayol.
Town had begun brightly, bossed the opening period and deserved their advantage, but the visitors made a good fist of things after the break, and Miller’s goal ensured a more comfortable finish as well as a fifth victory of the campaign.
Wagner made four changes in the wake of the defeat by Bristol City, handing midfielder Duane Holmes a first start since the 2013-14 season and recalling centre-back Joel Lynch after a hamstring injury.
Harry Bunn and Mustapha Carayol also returned, with injured duo Emyr Huws (hamstring) and Martin Cranie (thigh) missing out and Joe Lolley and Jamie Paterson on the bench.
Top scorer Nahki Wells passed a fitness test after suffering an ankle problem on Saturday.
Holmes took up one of the two deep-lying positions alongside Jonathan Hogg and was soon in action, driving forward to tee up Sean Scannell for a shot which hit the side netting.
Carayol had already had a shot deflected for a corner as Wagner’s side made a much brighter start than against Bristol City.
Even so, it took a fine tackle by Lynch to dispossess ex-Town man Danny Ward as he shaped to shoot in the sixth minute.
Town were soon back on the attack, and Ben Chilwell crashed a shot narrowly off target after being played in by Carayol, who then touched a free-kick to Bunn, whose fizzing effort was just wide.
The game lost some of its tempo and shape for a spell as Rotherham dug in, although Lynch pushed forward in the 21st minute, and with the home fans remembering some spectacular goals in the past and shouting for him to shoot, came close from distance, the ball going just wide.
Where Lynch failed, Carayol succeeded 10 minutes later, netting with a dipping 25-yard strike which deceived Rotherham keeper Lee Camp and flew into the back of the net.
It was Carayol’s second goal for the club and the first time Town had been ahead in a home game under Wagner.
Carayol freed Bunn with a deft pass in first-half stoppage time, but Camp was equal to his hooked attempt on goal.
Town began the second half with Ishmael Miller on in place of Wells, while skipper Mark Hudson had to be alert to cut out Grant Ward’s early cross from the right.
Rotherham continued to push forward, with Hudson and his fellow defenders kept busy for a spell as the home team struggled to rediscover their rhythm from the opening period.
Lynch made a key block from Jonson Clarke-Harris as the visitors forced two corners in quick succession.
Wagner made his second change, bringing on Lolley for Scannell, in the 58th minute, before keeper Jed Steer preserved Town’s lead by blocking Joe Newell’s shot with his legs.
Town made their third change in the 71st minute, bringing on Jamie Paterson for Holmes, who was given a rousing ovation by the home supporters.
Within minutes, Miller was the name on their lips as the striker charged forward, got past defender Danny Collins and coolly slotted the ball last keeper Camp for his side’s second goal.
Town had an escape when Clarke-Harris’s shot hit the left-hand post and bounced back into the hands of the grateful Steer, but the faithful remained in great voice, particularly when Clarke-Harris thumped a dangerous-looking free-kick straight into the Town wall.