Sunderland dominated for the majority of the game but their failure to deal with long throws cost them a vital three points.
Story of the game
Lafferty gave Sunderland the lead on his full debut after 64 minutes.
Mikael Mandron finished neatly in the 74th minute to put Gillingham level.
Lafferty put the home side back in front after 83 minutes.
Mandron levelled things up again in the last minute of added-on time.
After a sloppy start to the game from both sides, Sunderland had the first half-chance as Tom Flannagan slipped his marker at the back post, but saw his misjudged header go wide of the far post
Sunderland squandered a glorious chance after 28 minutes as Denver Hume's cushioned pass fell to Lynden Gooch but he was denied twice by Jack Bonham from close range.
Chris Maguire was twisting and turning in the box before creating space from himself but his effort was fired straight at Bonham.
Gillingham failed to clear a free-kick on the stroke of half time and the ball feel to Flanagan and his shot was heading for the bottom corner before a deflection sent it marginally wide of the post.
The visitors played some better football at the beginning of the second half as Jordan Roberts broke into the box after 55 minutes but his shot only stung the palms of Jon McLaughlin.
Lafferty should have scored on his full debut for Sunderland a minute later Hume picked him out six-yards from goal but sent his shot wide of the near post despite being unmarked.
Two minutes another chance goes begging for the Black Cats this it is Luke O'Nien who picks out a low cross for Maguire but he got the ball stuck under his feet allowing Bonham to dive on it only two-yards from going in.
Gillingham could have taken the lead just after the hour mark when Brandon Hanlan broke through and his miscued shot was smartly pushed away by Mclaughlin.
The home side broke from that chance, went down the other end and punished Gillingjam as Hume's cross was met superbly by Lafferty who headed home from inside the six-yard box.
Lafferty out strengthed Jack Turner in the box to leave Bonham no chance of denying him a goal on his full debut for the Black Cats.
A long throw into the box saw Mandron miss his volley but he reacted quickly to the loose ball and managed to squeeze his effort through a number of bodies and into the far corner.
Two minutes later Mandrom latched onto John Akinde's flick-on but saw his fizzing effort tipped away for a corner by McLaughlin.
Sunderland were lucky to still be level as from the resulting corner Tucker found himself free at the back post and the Black Cats had McLaughlin to thank once again as he made a solid save at his near post.
After constant pressure, Gillingham shot themselves in the foot as Thomas O'Connor got disposed in the middle of the pitch and one pass later Lafferty was through on goal before applying a calm finish beneath Bonham.
In dramatic fashion, Mandron got his second of the game from another long throw and he fired from the edge of the area into the corner leaving McLaughlin with no chance,
Decision making has to improve
Sunderland were the better side for a lot of the game, however, their decision making in the final third and in their own box cost them greatly.
They had a number of chances to have a shot at goal but instead took an extra chance or another pass which scuppered the chance.
In their own box they were either too tight to the Gillingham players or not tight enough which is how both of the visitors' goals came about.