SOUTH BEND, Ind. (AP) — Ian Book ran 7 yards for a touchdown with 29 seconds left to cap an 18-play, 87-yard drive and No. 16 Notre Dame pulled out a 21-20 victory against Virginia Tech on Saturday.

The Fighting Irish averted a second straight loss, following last week’s 45-14 rout at Michigan.

“That was a great character victory for our football team,” Irish coach Brian Kelly said. “They endured a lot this week. They found a way to win.”

Book said the go-ahead touchdown on third-and-goal was a designed run.

“This week was about our team,” Book said. “It was about having that strong love for each other and just going out there for one another and playing for each other.”

The Irish had committed three turnovers deep in Virginia Tech territory, including a fumble at the goal line that Divine Deablo returned for a 98-yard touchdown to tie the game at 14 with 9 seconds left in the first half.

The Hokies (5-3) added a pair of field goals by Brian Johnson in the second half and the Irish missed one, leaving Notre Dame trailing by six with 3:19 remaining and the ball at its 13.

Book led a methodical drive, converting two fourth downs, including a fourth-and-10 at the Tech 33 for 26 yards to Chase Claypool that gave the Irish first-and-goal from the 7. After two incomplete passes, Notre Dame caught Virginia Tech in a blitz and Book ran away from it and darted into the end zone. Jonathan Doerer booted through the PAT for the lead, Kyle Hamilton picked off a long pass by Quincy Patterson and the Irish averted a two-game losing streak.

“It’s a tough locker room in there,” Virginia Tech coach Justin Fuente said. “It’s a group of guys that played hard, prepared well for a very good football team on the road in a hostile environment and almost pulled it off.”

Book had 341 yards on 29-of-53 passing and two touchdowns and also led the Irish with 50 yards on 13 carries as Notre Dame outgained Virginia Tech 447-240.

Patterson got the start for Virginia Tech at quarterback in place of Hendon Hooker, who had started the three previous victories but suffered a knee injury in Virginia Tech’s 43-41 six-overtime victory over North Carolina two Saturdays ago.

Patterson ran for 77 yards on 19 carries and completed 9 of 28 passes for 139 yards and an 8-yard touchdown to Damon Hazelton in the second quarter.