STANFORD >> Stanford coach Troy Taylor told the seniors to make their last game at Stanford Stadium one that they’ll never forget. The whole team took it to heart.

Stanford snapped a six-game losing streak and won its first home game over an FBS team in the Taylor era in improbable fashion. The Cardinal overcame a 14-point fourth-quarter deficit, and senior Emmet Kenney kicked a career-long 52-yard field goal as time expired as Stanford defeated No. 22 Louisville 38-35 on Saturday.

“In life you know the first time you do something, but usually you don’t know the last time you do something,” Taylor said. “For a lot of these guys, it’s the last time playing at Stanford Stadium. We talked about breathing it in, enjoying it, and then making it memorable, and we certainly did that.”

Emmett Mosley V had the most productive game for a true freshman receiver in program history, catching 13 passes for 168 yards and three touchdowns. He caught two fourth-quarter TDs in the final seven minutes, including a 4-yard pass from Ashton Daniels on fourth-and-goal and then a 25-yard pass from wildcat QB Justin Lamson on fourth-and-1 with 45 seconds left, allowing Stanford (3-7, 2-5) to tie the game at 35.

The Stanford defense was missing sixth-year linebacker and captain Tristan Sinclair and junior Collin Wright, its best player in coverage, who were both injured. But the unit, which is last in the ACC in points allowed, forced Louisville to turn the ball over on downs at the Stanford 45 with five seconds left.

Louisville (6-4, 4-3), a 21-point favorite, then self-destructed to allow the shocking upset. Louisville committed a personal foul penalty on a 1-yard reception by Mosley to set up a 57-yard field goal attempt with one second left. Then a Louisville player jumped offsides to move the ball five yards closer.

Kenney, who came to The Farm from Fargo, North Dakota but spent his first three years either injured or backing up current Los Angeles Rams kicker Joshua Karty, then nailed a career-best kick on senior day, sending the players and a small group of students storming onto the field.

Kenney hit a 39-yard field goal as time expired as Stanford won its first-ever ACC game 26-24 at Syracuse. The Cardinal hadn’t won since, including five losses by at least 24 points. But Taylor, whose overall record at Stanford is 6-16, improved to 3-0 after a bye week, and the Cardinal seemed to use the extra week to its advantage.

Senior linebacker Gaethan Bernadel intercepted a pass that was tipped by junior tackle Zach Rowell on Louisville’s first possession, and Mosley caught a 62-yard touchdown pass from Daniels to put Stanford up 10-0. Mosley, a four-star receiver from Santa Margarita, had 22 catches for 193 yards going into Saturday.

“It means the world for a group of guys to be able to stick together and do what we just did,” Daniels said. “We’re not in bowl contention anymore, we can’t get that sixth win, but it says a lot for the guys to stick together, love each other and just be optimistic about everything.”

The Cardinal had lost 12 straight games against FBS opponents at Stanford Stadium, including all 10 in Taylor’s two years at the helm. Louisville’s previous losses this season had all been against AP Top 15 opponents.

“I’m really happy for our seniors that they get rewarded,” Taylor said. “They chose to stay here when a lot of people left. I’m forever grateful and a lot of respect and admiration for this group. Just really, really happy for them.”

About 30 players transferred after the 2022 season when David Shaw retired or after Stanford went 3-9 in Taylor’s first year.

Bernadel, who started his career at Florida International, was one of the few players who transferred in. Stanford hasn’t won more than four games in a season since 2018, but Bernadel said that games like Saturday’s are laying a foundation for a promising future.

“Obviously, we haven’t had the season that we wanted to, but just being a part of the growth, the team that got it going,” Bernadel said.

“We’re going to be great, trust me.”