WEST POINT, N.Y. -- When fifth-ranked Stanford went to the locker room at halftime leading Army by only seven points, head coach David Shaw realized he needn't worry.
"What I love about the team today is that, when people tell you you're supposed to win the game by a lot, you come in at halftime and it's close, if you listened to the outside people you'd get a little anxious," Shaw said. "In the locker room at halftime, we were not anxious. We knew we had to play our best, came out in the second half, and played great."
Played to a near standstill the first two quarters by a 30-point underdog, the Cardinal regrouped in the second half and beat the Black Knights 34-20 on Saturday. Kevin Hogan threw for three touchdowns and Tyler Gaffney had two touchdowns and 132 yards rushing for the Cardinal (2-0).
Still, Stanford had its hands full against Army's triple option offense, falling behind 6-0 at the outset as the much smaller Black Knights (1-2) challenged at every turn.
"They came out there with a little bit different approach than what we had seen," said defensive end Josh Mauro, who led Stanford with seven tackles. "It just took guys having the will to do their jobs. We made some adjustments in the second half to stop the inside run. We got the look all week, but it's so much different when you're actually doing it. All the credit to them. They played their butts off."
Hogan's 23-yard touchdown pass to Gaffney after an Army turnover gave Stanford a 27-13 lead late in the third quarter and the Cardinal averted an embarrassing moment. Army has not defeated a ranked team since a 17-14 win over No. 15 Air Force on Nov. 4, 1972.
"We kept our calm. We tried to keep an even keel," Gaffney said after his second straight solid performance following a year of minor league baseball. "We went out there knowing that six points wasn't going to win the game. We went out there with the same mindset, keep grinding. We didn't overlook them. We had to keep grinding. We were down. Adversity stepped in and we responded."
Ty Montgomery had six catches for 130 yards and one score, while Hogan was 11 of 18 for 188 yards passing for Stanford.
Terry Baggett led Army with 96 yards rushing on nine carries.
Done in by three turnovers and eight penalties in a 40-14 loss last week at Ball State, Army needed to play a flawless game against the Cardinal to have a fighting chance and acquitted itself well. The Black Knights forced the lone turnover of the first half as neither team was penalized before the break.
The most critical play came in the third quarter. Trailing 20-13 and poised to tie the game, Army quarterback Angel Santiago botched a third-down handoff after the Black Knights had driven into Stanford territory, and James Vaughters recovered the fumble for the Cardinal. Montgomery's 27-yard catch on a third-and-7 play set up Gaffney's touchdown catch.
"We didn't play the game we wanted to play," Baggett said. "Our goal coming into the game was to win. There were about three offensive plays offensively that changed this game. We have to make those plays every time. It's a step in the right direction, but it's not the final step for us."
Army failed on a fourth-and-1 play early in the fourth quarter inside its own 30 and the Cardinal secured the victory on Gaffney's 1-yard run.
Stanford's rushing defense has posted the best numbers in school history the past two seasons, allowing 84.4 yards per game in 2011 and 97 per game last year. Army's triple option led the nation in rushing both years, averaging a school-record 369.8 yards per game and accumulating 4,438 yards on the ground in 2012.
The Black Knights, despite the loss of four-year starter Trent Steelman at quarterback, entered Saturday's game on pace for another strong year, averaging 329 yards rushing in splitting their first two games. Not quite so effective without Raymond Maples and Larry Dixon, who were hurt in the game and sat much of it, the Black Knights still finished with 284 yards rushing on 61 carries, and inspired play by the Army defense kept the game close for most of the first three quarters.
"They didn't do anything different. We've seen everything they did on film," Mauro said. "It's just so different actually being out there, the speed they go. Those linemen are undersized, but they're the quickest offensive line probably in the nation. Those guys are really good at what they do. It's hard to simulate that in four days and do it on Saturday, actually see the real thing."