The Cardinal (10-2) overcame two interceptions from Kevin Hogan and a penalty that wiped away another touchdown to win their 16th consecutive home game. Stanford will play for its second straight Pac-12 title and Rose Bowl berth next week when it faces No. 13 Arizona State in the conference championship game.
If Arizona State beats rival Arizona late Saturday night, the conference championship will be held in Tempe, Ariz. Otherwise it will be at Stanford, which handed the Sun Devils their only league loss this season.
The final tuneup for that game turned out to be another tough test.
Rees nearly rallied the Fighting Irish (8-4) by throwing two touchdown passes later in the quarter. But interceptions on Notre Dame's final two drives dashed Notre Dame's comeback.
Stanford relied on its power running game to control the tempo throughout, but blew several chances to pull away.
Gaffney plowed through the Irish line from a yard out to give the Cardinal a 14-3 lead early in the second quarter. The bunched formation was similar to the one Notre Dame stopped Stepfan Taylor last year to win in overtime, a stinging loss that the Cardinal regrouped from to roll off eight straight victories, including the Pac-12 title and the Rose Bowl.
Backup Anthony Wilkerson capped the opening drive of the second half in similar fashion. He ran for a 20-yard TD run on third-and-9 to put Stanford ahead 21-6.
Notre Dame drove deep in Stanford territory on its first and final drives of the first half before settling for field goals each time. With Stanford seemingly ready to turn the game into a rout, Rees rallied the Irish by throwing touchdown passes to T.J. Jones and DaVaris Daniels late in the third quarter.
Mistakes nearly cost the Cardinal late.
Stanford had no problem sustaining drives but struggled to finish them with touchdowns in the second half, twice settling for field goals. On one of them, a holding penalty on right guard Kevin Danser -- only the second one by a Stanford offensive lineman all season -- erased a touchdown rushing for Gaffney.
Hogan threw his second interception of the game when Bennett Jackson came down with his pass at Notre Dame's 21 with 6:23 remaining. Austin Collinsworth also intercepted a pass from Hogan in the first half.
Just as it has so many times over the past two seasons, the Cardinal defense bailed out the offense in the end.
Lyons intercepted Rees' overthrown pass at Stanford's 41, the 36th straight game the Cardinal have forced a turnover. And after the Irish stopped Stanford three-and-out, Lyons leaped high to intercept Rees' pass again on Stanford's 30 with 2:24 left.
The Irish already had beaten Arizona State and Southern California and were looking to go 3-0 against the Pac-12 this season. Instead, they fell to a team that hopes to win a second straight Pac-12 title.