Arizona (3-2, 1-1) took possession on its own 20 with 1:56 left, and appeared to have stalled around midfield before Smith, with 5 seconds left, launched a desperation pass into a crowd of players in the end zone.
It was the 12th loss in a row for Washington State (0-4, 0-2), third longest losing streak in the nation. They have not won since Sept. 19, 1998, and have not defeated a Pac-10 team since the 1997 season.
Trung Canidate rushed for 158 yards and three touchdowns to lead Arizona. Arizona kicker Mark McDonald missed four field goals in the game, and all six of his attempts this season.
Arizona struck first, on Canidate's 1-yard touchdown burst midway through the first quarter.
Washington State tied the game on Steve Birnbaum's 11-yard touchdown pass to Farwan Zubedi with 1:31 left in the half.
Rian Lindell's 52-yard field goal gave WSU a 10-7 halftime lead.
McDonald missed field goals attempts of 53 and 40 yards in the first half, and 43 yards and 32 yards in the second half.
McDonald faked a 52-yarder in the third quarter, but instead tried to bury WSU with a short punt. The Cougars took possession on their 20.
After an offsides penalty put the ball on the 15, WSU running back Deon Burnett fumbled, with the ball bouncing into the end zone. Quarterback Steve Birnbaum fell on it for an Arizona safety, cutting WSU's lead to 10-9.
Later in the third, the Wildcats' Dennis Northcutt returned a punt 68 yards to the WSU 13, with Billy Newman making the touchdown-saving tackle.
Canidate run in untouched from the 2, and Keith Smith passed to Brandon Manumaleuna for a 2-point conversion and a 17-10 Arizona lead after three quarters.
Jason Gesser replaced Birnbaum at quarterback for the Cougars late in the third. On his second series, Gesser directed an 80-yard drive in seven plays, capped by Burnett's 2-yard touchdown run to tie the game at 17-17 with 10:15 left.
The Wildcats responded with an 80-yard drive of their own, with Canidate rushing nine times. The last was a 4-yard burst up the middle to give Arizona a 24-17 lead with 4:39 left.
After Newman returned the kickoff to the WSU 45, Burnett ran 55 yards down the left sideline for a touchdown. Lindell's extra point tied the game at 24-24 with 4:14 left.
The Cougars punted from Arizona's 45 with 1:56 left, giving the Wildcats the ball on their own 20 to start the winning drive.