A brace from Cody McDonald secured a win for Gillingham over high-flying Peterborough.
McDonald headed the Gills in front but it was all-square by the break when Jon Taylor netted for the visitors.
Late in the game McDonald put the Gills 2-1 ahead from the penalty spot to clinch the points.
Victory maintained Gills’ unbeaten start at home in the league, stretching the run to four games.
Gills boss Peter Taylor made two changes to his starting XI for the visit of second- placed Peterborough.
Captain Doug Loft was back for the first time since the home game against Yeovil a month ago.
Striker Luke Norris also made a rare start for the Gills. Losing out were Brennan Dickenson and Callum Davies, who both made the bench.
Peterborough were chasing a fourth successive away win and were captained by former Gills midfielder Jack Payne.
The visitors looked dangerous early on and winger Jon Taylor drew a couple of early saves from Stephen Bywater.
But it was the Gills who opened the scoring. Bradley Dack’s cross was only pushed away by keeper Ben Alnwick and the follow-up cross from Jake Hessenthaler was headed in by McDonald.
The goal changed the tide of the game and the Gills looked good for a second goal.
John Egan headed a Dack cross wide and Loft’s long-range effort was saved by Alnwick, tipping it just wide.
But hopes of reaching the break with a goal lead ended when Taylor scored with a real fluke effort. Two minutes before half-time he whipped in a cross that flew over Bywater.
The visitors started the second half in positive mood but 10 minutes in Dack had a low angled shot nudged wide by Alnwick.
On the hour Peterborough’s half-time sub Joe Newell curled an effort past Bywater but it bounced to safety off the post.
The Gills retook the lead with four minutes left when McGlashan side-stepped defender Christian Burgess and he handled in the box. Alnwick got a hand to the spot-kick but couldn’t prevent it from going in.
Gillingham: Bywater, Martin, Egan, Hause, Loft (Pritchard 73mins), A Morris, Dack, Hessenthaler (Linganzi 73mins), McGlashan, McDonald, Norris (Dickenson 80mins). Subs not used: Legge, G Morris, German, Davies.
Peterborough: Alnwick, Smith, Baldwin, Taylor (Ferdinand 70mins), Payne, James (Washington 77mins), Vassell, Anderson (Newell 46mins), Burgess, Santos, Maddison. Subs not used: Brisley, McCann, McEvoy, Grant.
Attendance: 4,819 (282 away)