LOUISVILLE, Ky. — Jameis Winston threw three touchdowns to offset a three-interception start and Dalvin Cook had two long scoring runs to help second-ranked Florida State rally for a 42-31 victory over Louisville on Thursday night.

Florida State overcame a 21-0 deficit for its 24th straight victory, with Cook giving the Seminoles the lead for good with a 38-yard run with 3:46 remaining.

Out of sorts and on the verge of having its College Football Playoff prospects damaged, the Seminoles (8-0, 5-0 Atlantic Coast Conference, No. 2 CFP) recovered behind their Heisman Trophy quarterback and Cook, who had a 40-yard touchdown run in the third quarter.

All of Winston’s TD passes were big. He hit Travis Rudolph for 68 yards, Ermon Lane for 47, and Freddie Stevenson for the 35-yard clincher with 2:11 remaining.

Winston was 25 of 48 for 401 yards. More important for the Seminoles was maintaining their national championship hopes on a night that Louisville (6-3, 4-3, No. 25 CFP) nearly took them away twice.

The presence of Muhammad Ali was fitting in a game that the Cardinals initially dominated with a smashmouth approach that provided a 21-point first-half lead and knocked the Seminoles on the ropes. Michael Dyer had TD runs of 4 and 12 yards and Gerald Christian caught an 11-yard scoring pass from Will Gardner.

Florida State began its comeback just before halftime when Winston, shaking off two interceptions that Louisville turned into 14 points, led the Seminoles 78 yards on a drive that ended weird touchdown when Nick O’Leary recovered Karlos Williams’ fumble in the end zone.

The intermission gave Winston and Florida State time to regroup, though not before his third interception and second by Louisville safety Gerod Holliman. Ironically, Winston’s biggest play came after the pickoff as he came up and stripped Holliman of the ball, which Travis Rudolph recovered at the Florida State 40.

The Seminoles turned it over on downs but Winston found Rudolph wide open down the middle between two defenders for a 68-yard TD strike that cut it to 24-14 with 9:51 left in the quarter.

Florida State’s swagger was back.

Cook turned it into a 40-yard touchdown run nearly 4 minutes later to bring the Seminoles within a field goal.

Winston’s TD pass to Lane with 12:48 left provided Florida State’s first lead and the game became a slugfest from there as Dyer answered for Louisville with a 1-yard TD run with 9:20 left. The Seminoles took charge from there with Cook’s TD run and Stevenson’s pass from Winston.

Louisville’s loss spoiled a career night for wide receiver DeVante Parker, who caught eight passes for 214 yards.

Dyer was destined to be a hero as well with 28 carries for 134 yards and three touchdowns, while Gardner completed 20 of 38 passes for 330 passes.

In the end the Cardinals were overshadowed by Florida State and Winston, whose poise after a bad start kept the Seminoles in the running for their second straight national title.

But it took overcoming a Louisville team that wasn’t fazed by the Seminoles’ standing, quarterback or anything else for that matter.

Louisville charged the crowd of 55,414 on the game’s first play as Gardner hit a wide-open Parker down the middle for 71 yards to the Florida State 4. Three plays gained 6 more yards but the Cardinals eventually turned it over on downs as Gardner’s fourth-and-goal pass sailed past Gerald Christian, among several receivers well covered by the Seminoles.

Louisville’s missed opportunity wasn’t costly thanks to its nation-leading defense that kept Winston and Florida State from getting started. Despite crossing midfield twice, the Seminoles never got much further as the Cardinals pressured the Heisman Trophy winner while covering his receivers.