"We really had to dig in to win this game," said Gray.
"Mark Bunn made some good saves and the most important thing is we are in the hat for the next round.
"I thought we did very well for the first 25 minutes and we should have been more than one up.
"After that Millwall came back into the game but it was their first home game of the season so you would expect them to have spells in the game where they get on the front foot and create chances."
Northampton are one of the non seeded teams in the 2nd round draw.