Andre Gray came off the bench to score the winner in a tight tussle at Vicarage Road