STANFORD, Calif. (AP) — Marcus Sheffield hasn't scored much this season. When he's needed, though, he's ready.
Sheffield, who missed of all last year with an injury, scored a season-high 16 points, including a key 3-pointer, and Stanford rallied to beat Southern California 79-76 on Wednesday night.
"I stay prepared, come in and play defense," Sheffield said. "The shots are going to come."
Bryce Wills scored four of his 11 points in the final 14 seconds and KZ Okpala added 18 points for the Cardinal (13-11, 6-6 Pac-12), who has won four of its last five. Josh Sharma added 14 points and had nine rebounds.
"His shooting is a big piece of what he brings," Stanford coach Jerod Haase said. "He brings stability. He's even-keeled."
Bernie Boatwright scored 19 points to lead the Trojans (13-12, 6-6), who lost at Stanford for a fifth straight time. Nick Rakocevic scored 15 points and had 11 rebounds.
"Our biggest takeaway from this game is that our upper classmen have to be able to finish games in the last minute, and they have to do a better job, point blank," Trojans coach Andy Enfield said. "It was a good game. Both teams played hard, played well, and it came down to the end, and we could not finish. Very simple."
Wills hit a layup with 14 seconds remaining to put Stanford ahead 77-76. He missed an ensuing free throw and USC called time to step up a play.
"Coach tells us to keep fighting," Wills said. "We fought back."
Boatwright missed a jumper and Wills grabbed the rebound.
"That didn't decide the game," Enfield said. "We missed two free throws with a minute left up four, and then we turned the ball over in the next possession on a terrible pass, and then we gave up a right hand layup for them to take the lead."
Sheffield hit a 3-pointer to bring the Cardinal within 76-75 and Sharma made a key steal at the other end.
"It was a set play," Sheffield said. "I came off my screen and knocked it down."
The Cardinal trailed by as many as 14 points before bouncing back.
Stanford took its first lead of the game with 12:02 remaining to play when Sharma sank a short jumper for a 52-51 advantage.
Seven lead changes and four ties later, USC took a 74-72 lead on a short jumper Derryck Duncan.
Kevin Porter Jr. scored 10 points in the early going and the Trojans took a 40-35 lead into halftime.
Until its victory at Washington State 11 days ago, USC was on a six-game losing streak away from the Galen Center. ... Jonah Mathews, who scored 16, had his streak of 28 games with at least one 3-pointer snapped in his last game. He hit the first two he took on Wednesday. ... USC lost for the first time when leading at the five-minute mark (12-1).
Sharma is averaging 11.1 points, 8.1 rebounds and over 70 percent shooting from the field over his past eight games for Stanford. He averaged 7.8 points and 4.9 rebounds over his first 16 games. ... Stanford played without point guard Daejon Davis, who missed his second straight game with an upper body injury.
USC plays at California on Saturday.
Stanford hosts UCLA on Saturday.