Stanford’s lone first-half tally came on a Logan Panchot free kick from 25 yards out that the junior sent to the back post. Keegan Hughes rose and put a great header on frame that was touched in by fellow freshman Gabe Segal in the 37th minute. The goal was Segal’s fifth of the season and came four minutes after he subbed on.

The Aztecs put in two in the first half to take a 2-1 lead at the break. Following a little bit of miscommunication from the Cardinal at the back, Tevenn Roux slipped his shot past Andrew Thomas in the 19th minute and after Stanford was whistled for a penalty on a SDSU corner in the 41st, Adam Vargas stepped up and converted for the Aztecs.

The win extended Stanford’s unbeaten streak against the Aztecs to 17 (14-0-3) and helped the Cardinal (11-1-2, 4-1-1) move up the Pac-12 table and into a second-place tie with Oregon State on 13 points and with a game in hand on the Beavers.

Stanford finally found its equalizer in the 76th minute when Waldeck put in a tremendous looping ball over the top. Freshman Ousseni Bouda used his blazing speed to beat everyone to the ball, nicked it past the charging Aztec keeper and put on a fantastic finish.

“You’re behind and you’ve got ground to make up,” Gunn said. “The first half didn’t go to plan and we had to do better in the second half and we certainly did. We created better chance and had better finishes. It’s a testament to the players to really come on strong, take the game to SDSU and finish it off. These are games that can absolutely go either way. It wasn’t our best performance, but it was a gutsy one.”

Panchot’s free kick from outside the box was initially saved, Hughes’ attempt on the rebound was blocked and Derek Waldeck’s header at the end of the sequence skipped wide. All three shots came within a five-second span and could have proved to be one of many frustrating scoring chances on the night, but the Cardinal kept working.

Nonetheless, Stanford was playing from behind in the second half and nearly leveled it right out of intermission in the 47th.

“That’s what a striker should do and that’s what’s so great about Gabe,” Cardinal coach Jeremy Gunn said “He’s so lively and alert in the box and sniffing out those chances. That’s the best part of his game.”

The Cardinal is back in action on Sunday at 3 p.m. against UCLA. Stanford’s senior class of Tanner Beason, Jared Gilbey, Matthew Radzihovsky and Derek Waldeck will be honored in a pregame ceremony in front of the west stands at Cagan Stadium.

Zach Ryan won it in the 81st minute when he knocked in Panchot’s corner for his team-leading sixth score of the year. Stanford’s three goal scorers in the win – Segal (5), Bouda (5), Ryan (6) – are its three leaders in that category this season.

Stanford men rally late to win Pac-12 soccer match