"They dominated the game and beat us every way you can tonight," Arizona State coach Todd Graham said. "They obviously were the better team and deserved to win."
Stanford won the first meeting 42-28 by racing out to a big lead and holding a Sun Devils' charge.
A lot happened in the 11 weeks since: Arizona State won seven straight to clinch the Pac-12 South and Stanford won the North despite losing twice.
The Cardinal got off to another fast start in the rematch: Gaffney raced 69 yards down the sideline for a touchdown that turned the raucous crowd inside Sun Devil Stadium nearly silent.
The Sun Devils had a quick counterpunch this time, scoring on their fifth play when Foster charged through up the middle for a 51-yard touchdown, eclipsing Arizona State's entire rushing total (50) from the first meeting.
But Stanford followed with a series of body blows, churning out big plays behind its massive offensive line.
Gaffney scored on a 1-yard run after Hogan hit Jordan Pratt on 35-yard pass. Montgomery scored on the first play of the second quarter, racing in 22 yards on an end-around after Hogan connected on a 42-yard pass to Devon Cajuste. A 29-yard run by Anthony Wilkerson set up Foster's third TD, a fourth-down dive that put the Cardinal up 28-7 early in the second quarter.
"We said all week not to let them make big plays and we didn't do that," Arizona State safety Alden Darby said. "We gave up three bombs to let them score and that set the tone."
Arizona State finally showed signs of life late in the quarter, when Foster broke a tackle and turned a swing pass into a 65-yard touchdown that cut the lead to 28-14.
The Sun Devils had a couple of scoring chances in the third quarter and came up empty.
Zane Gonzalez ended his school-record streak of made field goals 18 by missing a 31-yarder and Stanford's Zach Hoffpauir came off the corner to stuff De'Marieya Nelson on fourth-and-goal on Arizona State's second attempt from the 1.
Stanford put it out of reach thanks to another big play early in the fourth quarter. Hogan hit Cajuste on a 78-yard pass, then found Montgomery on a 24-yard touchdown throw to put the Cardinal up 38-14 and headed back to the Rose Bowl.