Brighton are still to win this term and defenders Tommy Elphick and Colin Hawkins were both sent off in the second half, while Stockport's Liam Bridcutt was also dismissed.
Striker Nicky Forster headed Brighton in front after 28 minutes but Baker responded two minutes later by converting a cross from Greg Tansey.
Stockport goalkeeper Owain Fon Williams brilliantly saved Forster's penalty four minutes after the break after Michael Raynes was penalised for bringing down Liam Dickinson.
Baker put Stockport ahead with a magnificent solo effort early in the second half, but Dickinson made it 2-2 from Forster's knock-down on the hour.
Elphick collected a second yellow card for a bad tackle on Tansey and Hawkins was also dismissed for handball in giving away a penalty which led to Baker completing his hat-trick after 66 minutes. Stockport had Bridcutt sent off for a second bookable offence before Oli Johnson sealed victory.