Stockley calmly side-footed home from close range after a goalmouth scramble, that the big striker's second goal of the season.
North End had been frustrated up until then as they laboured to break down a resolute Hatters side who sat deep and ran the clock down for much of the second half.
Paul Gallagher had given PNE a fourth-minute lead, following up to score after Luton keeper James Shea had parried his penalty - awarded for a foul on Patrick Bauer.
A penalty at the other end brought the visitors level just before half-time, Paul Huntington hardly judged to have tripped Callum McManaman.
James Collins scored from the spot and from then on they put men behind the ball to protect a point - something they managed to do until Stockley's late intervention.
Gallagher's return from injury was one of two changes made to the side which had beaten Fulham last Tuesday night.
He replaced Brad Potts in midfield with Darnell Fisher taking the place of the suspended Joe Rafferty at right-back.
North End were ahead inside four minutes, awarded a penalty when Bauer had his shirt tugged by Matty Pearson as he moved towards the back post to meet a corner.
Gallagher saw his spot-kick parried by Shea diving to his left but the PNE skipper followed up to knock home the rebound from five yards.
Luton responded with a couple of chances, Luke Berry side-footing a shot wide of the far post after the ball had been worked across the penalty box.
Then Andrew Hughes flung himself in the way of a McManaman shot to take it behind for a corner,
PNE were close to a second goal in the 21st minute, Hughes hanging a cross up to the far post which Billy Bodin headed goalwards, centre-half Pearson getting back to hook it off the line and over the bar.
David Nugent got his angles all wrong when meeting a Fisher cross, his header dropping wide of the target.
The game's second penalty saw Luton pull level two minutes before the interval.
Luton had counter-attacked down the Preston right after Bauer has lost possession just inside the Hatter half.
Kazenga Lualua broke forward and played a ball to McManaman in the box.
Huntington was shepherding McManaman and was adjudged to have clipped him from behind, although replays showed no contact.
Collins put the penalty away down the middle with Rudd having dived to his left.
Ten minutes into the second half, Josh Harrop was introduced off the bench to replace Nugent.
Sean Maguire went up front with Harrop taking up a position on the left.
In the 62nd minute after a Gallagher free-kick had been headed out of the box, Bodin tried his luck with a shot from 20 yards which drifted well wide.
Tom Barkhuizen and later Stockley were introduced from the bench as North End sought to find a winner.
The second half became increasingly frustrating as Luton sat men behind the ball and stifled any flow to the game.
The visitors were so close to snatching the lead in the 80th minute when Pearson misjudged a long ball forward and allowing Harry Cornick to steal it off him.
The substitute sprinted clear on goal but Rudd saved superbly with his legs.
What a vital save that proved to be, North End scoring four minutes later to retake the lead.
When a cross came over in the box, both Harrop and Gallagher had shots blocked in the goalmouth before the ball broke to Stockley who calmly stroked a shot into the net from six yards.
PNE: Rudd, Fisher, Bauer, Huntington, Hughes, Pearson, Gallagher, Bodin (Stockley 76), Browne (Barkhuizen 66), Maguire, Nugent (Harrop 56). Subs (not used): Clarke, Ledson, Potts, Hudson.
Luton: Shea, Bolton, Pearson, Bradley, Bree, Berry (Moncur 86), Butterfield (Tunnicliffe 61), McManaman (Cornick 67), Mpanza, Lualua, Collins. Subs (not used): Shinnie, Jones, Sheehan, Sluga.
Referee: Gavin Ward (Surrey)
Attendance: 12,083 (865 away)