Gillingham put an end to a run of three straight away defeats with a win at Carlisle.
On-loan striker Joe Pigott, making his first start for the Gills, put Peter Taylor’s side ahead late in the first half.
Cody McDonald added a second with two minutes left but an own-goal from Leon Legge in the final minute made for a nervy finish.
Gillingham hadn’t won in Carlisle for over 20 years and hadn’t scored in any of their last three visits to Brunton Park.
But it proved to be a happy day for the 194 travelling Gills fans.
Gills boss Taylor made four changes to the starting XI, with captain Adam Barrett among those coming back into the team.
Gillingham’s best early chances fell to the two centre backs. Barrett had a shot deflected over the bar and from the resulting corner Legge saw a low shot saved by keeper Jordan Pickford.
Carlisle had given the Gills an early scare, when striker Lee Miller got in behind Legge, but his subsequent shot failed to find the target.
In driving rain, neither side managed to take charge, but towards the end of the first half the hosts began to push the Gills back.
Despite the home side pressing, with a minute of normal time left, the Gills went ahead. Pigott released Cody McDonald and he made his way into the box. When the ball ran loose, the newcomer showed good composure before slotting home.
Gillingham held their lead into the break but only just. Michael Drennen tried his luck from distance and the rasping effort rattled the post.
The best of the early second half chances fell to Carlisle’s David Amoo but Nelson saved at the second attempt, after the ball bounced out of his hands from the initial shot.
Substitute Craig Fagan had a chance with almost an hour gone but keeper Pickford got down well to make the save.
Gillingham had solid appeals for a penalty when McDonald was taken down in the box by Pickford, as he raced onto Nelson’s long kick, but referee Mark Heywood waved play-on.
Miller was half celebrating an equaliser with 20 minutes left, as he headed goalwards, but the ball came off the inside of the post.
There was plenty of drama late on. McDonald put the Gills 2-0 up, as he took advantage of a slip by Courtney Meppen-Walter and tucked the ball home.
But 60 seconds later a cross from Matt Robson was put into his own net by Legge.
Gillingham: Nelson, Martin, Harriman, Barrett, Legge, Gregory, Dack, Smith (Fagan 21mins), Linganzi, McDonald, Pigott (Akinfenwa 65mins). Subs not used: Baxter, Davies, Lee, Hare, Hessenthaler.
Carlisle: Pickford, Robson, Chimbonda, Amoo, Miller, Ekangamene (Redmond 72mins), Potts, Berrett, O’Hanlon, Meppen-Walter, Drennan (Byrne 83mins). Subs not used: Noble, Thirlwell, Symington, Fleming, Guy.