Huddersfield robbed Swansea of their unbeaten record in the Sky Bet Championship as they won on the road for the first time in three months at the Liberty Stadium.
Marc Guehi forced Ben Hamer into the first save of the match in the Huddersfield goal with a long-range shot in only the fourth minute. That was the first of four shots on target in the first half from the home side, who also forced nine corners
Jamal Lowe almost opened the scoring in the 13th minute after being put through by Korey Smith, but Hamer made a brilliant one-handed save to keep the scores level.
Having been forced back into their own half for nearly all of the opening 20 minutes, Huddersfield finally pressed forward and scored from their first corner of the match three minutes later.
Juninho Bacuna exchanged passes in a short corner move with Carel Eiting, ran to the edge of the box, and fired in a fierce right-footed shot. Toffolo then guided the ball past Freddie Woodman in the home goal to give his side the lead against the run of play.
Within a minute the hosts were almost back on level terms. Viktor Gyokeres fired in a shot-cross from the right and Lowe just failed by inches to get his toe to the ball to direct it into an empty net.
Swansea were level in the 33rd minute after referee Tony Harrington ruled Hamer had impeded Smith as he went for an Ayew chip to the edge of the six-yard box.
Huddersfield were not happy, but Ayew was delighted to be able to celebrate his 100th appearance for the club with his 32nd goal.
Huddersfield, who had not won away since 1 July when they beat Birmingham 3-0, started the second half far more confidently and could have scored three times within 10 minutes.
Twice Isaac Mbenza went close, one effort hitting the post, and then Eiting failed to hit the target when it seemed easier to score.
Swansea then fluffed their lines at the other end as Ayew missed with a point-blank header from a Matt Grimes free-kick and then Lowe latched on to a poor back pass from Koroma and failed with two attempts to beat Hamer.
The catalogue of misses was eventually broken in the 67th minute when Koroma hit the target from inside the box to give Huddersfield the points.