The decisive moment arrived when Simon Church swung a cross in from the left for Jermaine Beckford to rise at the near post and nod his third goal of the season past Luke Steele nine minutes before the break at Oakwell.
Grayson said: "I thought throughout the course of the game we were very, not comfortable - because at 1-0 you're never comfortable in any game - but we created some good chances.
"The discipline of the team and the shape of the team got us through the game when other times we might have buckled under a little bit of pressure. Full credit to the players, they did ever so well because this is a difficult place
to come to."
Town could have won by a bigger margin with Lee Novak and on-loan Reading striker Church both denied by recalled Barnsley goalkeeper Steele in the second period.
Grayson added: "I think the keeper made some fantastic saves and at 1-0 you're always vulnerable. I'm delighted that we saw out in a professional manner a 1-0 victory. We limited Barnsley to very few opportunities which was obviously pleasing as well."