Report | Millwall 2-1 Fleetwood Town
Gregory was on hand to produce two precision finishes from the spot after 31 and 48 minutes to put The Lions 2-0 ahead, only for a super strike by Fleetwood sub Ashley Hunter to reduce the arrears with 25 minutes remaining.
But Neil Harris' men dug in and defended doggedly to withstand a late Town onslaught and clinch a welcome three-point haul.
Millwall went into action determined to bring an end to a run that had seen the team concede a goal in the opening 30 minutes in eight out of the last nine matches.
There was understandably a slight air of apprehension, but also quiet determination, and in the opening exchanges it took some solid defending by both Tony Craig and then Byron Webster to make important clearances to protect the home goal early on.
Former Lion Martyn Woolford perhaps could have done better with a good opportunity on 12 minutes, but glanced his header from a pinpoint David Ball delivery narrowly wide from close range.
Webster then showed good strength and positional sense to shield the ball out of play five minutes later, when the linesman's flag stayed down leaving David Ball sprinting shoulder to shoulder with the Lions defender into the penalty area.
A lunging challenge by Woolford on Ben Thompson earned the Fleetwood man a booking after 25 minutes, and from the resulting free-kick, Williams' curling 25-yard effort was heading for the top corner until keeper Chris Neal flung himself across his goal to tip the midfielder's effort over for a corner.
Williams took that set-piece too, and when the visiting defence could only half-clear, Thompson fizzed a low drive wide from long range.
Gregory then did well to twist and turn his way into the penalty area, and although surrounded by two defenders, still managed to squeeze in a shot that whilst on target, lacked the necessary power to trouble keeper Neal.
However, The Lions frontman had more joy with his next effort - drilling home a 31st-minute penalty opener low into the bottom corner after Fred Onyedinma had been fouled.
It was 2-0 within three minutes of the restart thanks to the clinical finishing of Gregory again, making no mistake from the spot for a second time after Webster had been wrestled to the ground by Nathan Pond as he tried to meet a Williams' corner.
It could have been a hat-trick for Gregory moments later when he latched onto a brilliant pass from Steve Morison, only to see his goal-bound drive blocked by the keeper.
Centre-half Craig was next to test the visiting defence with a firm header from another Williams' corner, but on this occasion the skipper's effort flew narrowly over the bar.
At this stage The Lions looked to be quite comfortable, but unfortunately all that changed with the introduction of Fleetwood sub Hunter, who halved the deficit with a curling left-foot effort in the 65th-minute after being allowed time and space to take aim from 25 yards.
Fleetwood then introduced striker Devante Cole looking to push on and grab the equaliser, and it took the reflexes of keeper Jordan Archer to keep out Cole's shot before a goalmouth scramble finally, thankfully, led to the ball being cleared.
However, it was The Lions who could have nicked a third as the game entered the final 10 minutes, but Gregory could only direct a header from Williams' dinked free-kick over the bar.
With Fleetwood continuing to push on in an increasingly desperate bid for a second goal, Lions boss Harris introduced defensive duo Martin and then Shaun Hutchinson to shore things up further as the home team stood firm in a nervy finale, including five minutes of injury-time, to bag all three points.
Scorer: Gregory (31, 48mins, pens)
Fleetwood Town: Neal, McLaughlin, Bell, Eastham (Bolger, 82mins), Pond, Ryan, Ball, Grant, Long (Cole, 69mins), Woolford (Hunter, 59mins), Dempsey. Subs not used: Cairns, Jonsson, Wallace, Sowerby.
Bookings: Woolford (25mins), Ryan (81mins)
Scorer: Hunter (65mins)
Ref: C Boyeson
Att: 8,058 (away 89)
Tweets by @MillwallFC