James Brophy pounced late on to clinch a well-earned win for Gillingham against league leaders Salford City.