An end-to-end first half littered with chances saw Stockport go in front after 13 minutes. Chris O'Grady did well to get in a low cross from the left, and in raced youngster Jamie Vincent who tucked in from 10 yards.
Ex-Stockport striker Anthony Elding saw a 25-yard volley saved by Conrad Logan, before Crewe levelled matters after 23 minutes.
Michael Rose upended Elding on the edge of the Stockport box, and up stepped left-back Billy Jones to curl the resulting free-kick into the top corner.
The Hatters went back in front four minutes into the second half. Tommy Rowe's shot was blocked, but O'Grady was on hand to lash home the rebound. Stockport went 3-1 up after 65 minutes when Oli Johnson produced a sublime chip from 20 yards to leave John Ruddy stranded.
Lawrence pulled one back for Crewe 11 minutes from time, but just two minutes later Johnson netted again for the hosts to make it 4-2. Sub Scott McManus scored from 30 yards in stoppage time, but it was too little, too late for 22nd-placed Crewe.