Gray replaces John Gorman, who quit the club just before Christmas as he continued to mourn his wife who passed away earlier in the year.
Cobblers chairman David Cardoza said: "We have sought the opinion of many people at all levels and they have all spoken very highly of Stuart and the professionalism that he brings with him.
"As soon as Gorman left we moved quickly and identified Stuart as a very strong candidate, he is one of the most respected and highly-rated young managers and coaches in the game.
"We are very excited about this appointment and we are sure that the fans will join me in welcoming Stuart to Sixfields.”