On fourth-and-11 from the 23 and trailing 14-10, Golson dropped back to pass and managed to avoid the Stanford rush just long enough to find Koyack as two Cardinal defensive backs tried to recover from the blown assignment.
Koyack caught the pass as he fell out of bounds, while safety Jordan Richards dove to try to break it up, and scored the winning touchdown with 61 seconds left to give the No. 9 Irish the 17-14 victory on a cold, rainy Saturday.
"I went to my first read and it wasn't there and I needed to begin improvising a little bit," Golson said. "I guess they busted the coverage a little bit and I found Koyack in the back of the end zone."
Koyack said he broke off his route when he saw the coverage and hoped Golson would see him.
"He did," he said. "It felt like the ball was in the air for about an hour."
Stanford coach David Shaw was asked what coverage the No. 14 Cardinal were in on the play.
"There was no coverage on Notre Dame's touchdown pass," he said. "That sounds sarcastic but he was wide-open. There was nobody on him."
Richards said Koyack got behind the Cardinal defense.
"I was just trying to head over there as fast as I could but I just couldn't do it," he said.
Golson struggled with accuracy at times and threw an interception and had a fumble that was hard to overcome, but still managed to pull it out.
Notre Dame coach Brian Kelly called Golson a winner, pointing out he is 15-1 as a starting quarterback. That 93.8 percent winning percentage is the best in school history.
"The kid's a winner and he keeps competing and he keeps playing," Kelly said. "And he has a bunch of winners around him. So you never feel like you're out of it. You just keep playing and keep giving it a shot."
The Fighting Irish improved to 5-0 for just the third time since Lou Holtz left in 1996 and the second time in three seasons. The Cardinal (3-2) have two losses this early in the season for the first time since opening 1-2 in 2008 in Jim Harbaugh's second season as coach.
Golson also threw a 17-yard TD pass to Chris Brown and Notre Dame amassed 370 yards of total offense against the nation's top defense. The game wasn't as exciting as Notre Dame's 20-13 overtime victory two years ago on a goal-line stand, but it was close.
The Irish defense held the Cardinal to 139 yards total offense and just 47 yards rushing. Stanford receiver Ty Montgomery, who entered the game averaging 69 yards a game receiving, was held to four catches for 12 yards. But he did have a 42-yard kickoff return that helped set up a Stanford touchdown late in the fourth quarter.
Shaw was disappointed the Cardinal defense couldn't hold on.
"We had a chance to seal it and we didn't," he said.
Stanford entered the game giving up 198 yards a game total offense and had given up only two runs of 25 yards or more. The Irish had 192 yards total offense at halftime and Golson had a career-long 33-yard run to set up a touchdown and C.J. Prosise had a 26-yard run that set up a scoring chance. Amir Carlisle had a 26-yard catch.
Golson was 20-of-43 passing for 241 yards with one interception and a fumble a week after having four turnovers against Syracuse. Kevin Hogan was 18-of-36 for 158 yards with two interceptions for Stanford.
Notre Dame had a chance to take the lead with 12 minutes left in the game, but holder Hunter Smith bungled the snap on a 27-yard try. Notre Dame kicker Kyle Brindza kicked the ball into the line and Stanford's A.J. Tarpley returned it 39 yards to the Stanford 44. The Irish also had a failed field goal attempt in the first quarter when Smith bobbled another snap and Brindza missed wide right on a 41-yard attempt.
But Smith got the ball down for a 45-yard field goal midway through the fourth quarter after putting gloves on. Kelly sarcastically called putting gloves on the holder "a revolutionary idea that will probably be now the biggest thing in college football."
Kelly said he was pleased with how the Irish, who were pushed around by Stanford his first year at Notre Dame, were able to compete despite being young.
"You bring the next batch of guys in and they're physically able to compete with arguably one of the more physical teams in college football," he said. "That's where you want your program to be after five years."