Williamson's kick broke a tie with 13:15 to play and the Spartans had three possessions the rest of the way in a bid to pull off the upset.
San Jose punted the ball away on two of the possessions with 5:23 and 3:31 remaining. The Spartans' final chance ended when quarterback David Fales threw a fourth-down interception from his own 30-yard line with 1:18 to go.
Stanford took a 14-0 lead in the opening quarter on a 1-yard scoring run by Stepfan Taylor and an 11-yard pass from Josh Nunes to Drew Terrell.
Nunes, playing his first game as the successor to No. 1 NFL draft choice Andrew Luck, completed 16-of-26 passes for 124 yards without an interception. Taylor gained 118 yards on 26 carries.
Stanford owned a 17-3 halftime lead, but San Jose State produced two touchdowns to tie it in the third period -- those coming on a 3-yard run by Blake Jurich and a 21-yard throw from Fales to Noel Grigsby.
Fales was 24-of-35 for 216 yards.