Dewayne Dedmon added 13 points and eight rebounds and J.T. Terrell had 12 points for the Trojans (12-13, 7-5 Pac-12), who have won four in a row. USC had lost nine of its previous 10 games at Maples Pavilion.
USC also swept the season series, having beaten Stanford 71-69 on Jan. 3 in Los Angeles.
Josh Huestis led the Cardinal (15-10, 6-6) with a career-high 22 points. Chasson Randle scored 16 points, including four 3-pointers, but missed a 3 attempt at the buzzer for Stanford, which had won four of its last five games.
Dwight Powell had 17 points and 17 rebounds—the most boards by a Cardinal in a game since Brook Lopez had 15 in 2008.
The Trojans led 35-23 at the half, capped by Dedmon's 30-footer at the buzzer. He led USC with 11 first-half points and Terrell scored nine on three 3-pointers—the only ones the Trojans would have in the game.
Huestis, who entered Thursday averaging 9.8 points per game, kept Stanford in it. He scored 15 of the Cardinal's points in the half, burning USC with outside shooting and slashing to the basket. Powell had 10 rebounds at the break.
USC led 65-59 with 41 seconds left, but Powell's three-point play cut the lead in half. After a Trojans turnover, Powell scored again on the inside to pull Stanford within 65-64 with 25.
Stanford fouled the Trojans' Eric Wise with 18.7 seconds to play. Wise missed both free throws, but Stanford got only one shot, Randle's corner attempt, and USC held on to move to 5-3 under interim coach Bob Cantu.
The teams began play tied for fifth in the Pac-12 along with California and Colorado, both of whom won Thursday. The three winners are now tied for fourth with Arizona State—two games behind conference leader Oregon—and Stanford is alone in eighth.
The Trojans shot 42 percent and Stanford made 44 percent of its shots from the field. USC was 18 for 23 from the free-throw line while the Cardinal managed just four free throws in 12 tries.