A strike by Jack Payne midway through the second half was enough to give the Kent side the win at Selhurst Park. The young midfielder, on as substitute for the injured Kevin Maher, ghosted into the Palace box to convert a low Andy Barcham cross.
The first half though was a wholly uneventful affair with neither side creating many chances of note as the first 45 ebbed away with a whimper.
Palace came closest on 40 minutes when Alessane N'Diaye was found all alone in the box and his header was well saved by Gillingham keeper Alan Julian.
The away side's chances though were limited to a series of long range efforts, striker Simeon Jackson saw a 30 yard strike dragged wide while winger Andy Barcham also saw his 25 yard effort fly high and wide.
The second half was a different affair with both sides opening up and adopting a much more attacking style of play.
Palace had the first chance of the half when Alan Lee, on as a substitute for Nathaniel Pinney, smashed a shot over the bar from 15 yards out on the angle.
While Gillingham's Adam Miller crashed a superb effort off the underside of the bar from 25 yards out.
On 53 minutes Sean Scannell, another half time substitute, did well down the right flank, twisting and turning his marker to free him up some space just inside the area before hitting a powerful left footed strike to the top corner that Julian saved well.
But N'Diaye had Palace's best chance of the half when he somehow conspired to miss from eight yards out.
A great ball from Hills into the six yard box was attacked by Lee and John and the ball rebounded into the path of the towering Frenchman who blasted over the bar with an open goal gaping.
The away side though managed to succeed where Palace had failed by taking their chance to take the lead.
A neat move between Andy Barcham and Curtis Weston allowed the former to get in behind the Palace defence on the left flank before playing in a low cross to an unmarked Payne who calmly slotted the ball home in front of his own fans.
Barcham then almost doubled the lead when he was played in to the area and smashed a rising drive that Flahavan saved well and Mark Bentley hit the far post late on for Gillingham, but the Kent side saw the final minutes out to take the win.
There will be exclusive highlights of today's match on Palace Player this week. To find out more about Palace Player and how to subscribe from as little as £3.99 a month click here.
Youngsters Nathaniel Pinney, Kieron Cadogan, Alassane N'Diaye and James Comley all given starts while Stern John was also included in the starting eleven.
Crystal Palace: 12. Darryl Flahavan, 9. Stern John (30. Michael Abnett, 70), 10. Nick Carle (31. Hakeem Adelakun,83), 15. Lee Hills, 17. Matt Lawrence, 20. Danny Butterfield (46. Jerry Nnamani, 83), 22. Johnny Ertl, 25. Nathaniel Pinney (19. Alan Lee, 45), 26. Kieron Cadogan, 28. James Comley (14. Sean Scannell), 31. Alassane N'Diaye (43. Charlie Holness,
Subs: 27. Simon Thomas, 32. Matthew Wright, 55. Charlie Mann
Gillingham: 23. Alan Julian, 2. Barry Fuller (Capt), 3. John Nutter, 4. Garry Richards, 5. Josh Gowling, 6. Kevin Maher (16. Jack Payne, 45), 7. Chris Palmer (19. Luke Rooney, 62), 8. Adam Miller, 9. Curtis Weston, 10. Simeon Jackson, 11. Andy Barcham
Subs: 12. Mark Bentley, 14. Mark McCammon, 15. Tom Wynter, 17. Connor Essam, 18. Rachid Yousseff, 20. Luis Cumbers