North End led after six minutes as Chris Humphrey showed superb control before angling in a shot from 14 yards.
Oldham enjoyed a spell of pressure, but Preston doubled their lead in the 71st minute when Humphrey set up Joe Garner for a tap-in.
Gary Harkins pulled one back after 75 minutes with a fine shot into the top corner, but Oldham went down to 10 men as substitute Jonson Clarke-Harris was shown a straight red card for handling Garner's header on the goalline.
Garner's resulting penalty was brilliantly saved by Mark Oxley, but he bagged his second goal two minutes from time with a dipping 20-yard drive to keep Preston six points behind leaders Wolves and four adrift of second-placed Leyton Orient.
Grayson said: "We could have been out of sight at half-time if we'd been more ruthless in the final third.
"We knew this was a difficult game, but we passed it around well and stopped Oldham playing.
"At this stage of the season you have to grind out points. That's what we did and it's a fantastic result.
"Oldham put us under pressure at times because they are a good team, but our second goal came at the right time.
"There were good individual performances and I'm pleased for Chris Humphrey.
"He has been very productive down the right and worked extremely hard.
"You also need players who will score goals regularly and Joe Garner hits the target more often than not.
"Everyone gets carried away looking at fixtures, but we'll just win every game we can.
"If the teams around us drop points, we are in with a chance."