A classic Ian Henderson lob had put Dale ahead at the break, despite missing from the penalty spot twice.
The hosts equalised shortly after the interval, and despite pressure from Dale, backed by 1,400 away supporters, it took until the final ten minutes before Gilmour scored the match winner.
Jimmy McNulty named an unchanged starting line-up from last week’s win at Altrincham, as Dale went in search of a fifth successive league victory.
The first half was a fair even affair in terms of efforts on goal, with the hosts forcing Nathan Broome into comfortable stops from Jack Nolan, George Thomas and Ludwig Francilette inside the first half an hour.
Henderson had earlier forced Jamal Blackman into a fine save, as the stopper denied his close-range header.
Harvey Gilmour sent a volley wide after Dale had won the ball high up the pitch, shortly before Joe Pritchard’s wicked free-kick delivery couldn’t be turned home by a blue shirt in the Morecambe area.
Dale had two golden opportunities to take the lead five minutes before the break via the penalty spot. Pritchard had been felled in the area, but Connor McBride saw his spot kick saved by Blackman.
However, the goalkeeper was deemed to have been off his line and the kick was to be retaken. Pritchard stepped up this time, going to the other side of Blackman, but the stopper made another fine save to deny him.
Broome was forced into action, again thanks to shots from range, as he tipped over Nolan’s swirling effort before holding Miguel Azeez’s shot.
It looked as though the scoreline would be goalless heading into the break, until a moment of magic from Dale’s all-time leading goalscorer. Broome sent a long ball forward through the middle of the pitch, over the top of the Morecambe defence, for Henderson to latch on to. He spotted Blackman off his line and, from 30 yards out, produced a classic Henderson lob for his 162nd Dale goal.
However, less than three minutes after the break, the hosts levelled, when Jack Nolan’s free-kick from the right crept in off the far post.
Despite the setback, it was Dale who had the majority of the second-half running.
Ryan Galvin headed over and half-time substitute Jake Burger shot wide after a nice turn.
Tyler Smith almost made an immediate impact when he turned Kyron Gordon’s low ball on target, only to be denied by Blackman. From the resulting corner, Charlie Waller’s header was superbly beaten away by the stopper.
It took until the final ten minutes for Dale to find a winner. Galvin kept the ball alive on the left side, finding Burger in the area. He in turn laid the ball off to Gilmour, who fired a first-time effort into the top corner from the edge of the box.
Burger sent an effort over late on as Dale kept pushing, and eight minutes of stoppage time passed without little worry for the defence, as McNulty’s men went two points clear at the top of the league.
Morecambe XI | Blackman, Kacurri, Francillette, Azeez, Aarons (74’ Muskwe), Sesay © (74’ Sangare), Tollitt, Sutton, Thomas (88’ Dixon-Bonner), Raikhy (63’ Lewis), Nolan.
Unused subs | Mair, Payne, Conte.
Scorers | 48’ Nolan.
Dale XI | Broome, Gordon, East (85’ Pettit), Ebanks-Landell ©, Gilmour, Adebayo-Rowling, Pritchard (46’ Burger), McBride (71’ Rodney), Waller, Galvin (85’ Moss), Henderson (63’ Smith).
Unused subs | Tutonda, Gomez-Mancini, Pettit, Moss.
Scorers | 45’ Henderson, 81’ Gilmour.
Attendance | 4,266 (1,400 away).