STARKVILLE, Miss. (AP) Mississippi State brought the all-out blitz. Alabama's Jalen Hurts never flinched.

Throwing two perfect passes with less than a minute remaining, the sophomore quarterback carved through Mississippi State's defense and helped deliver a precarious victory for the top-ranked Crimson Tide on Saturday night.

Hurts hit DeVonta Smith for a 26-yard touchdown pass with 25 seconds remaining to lift Alabama over No. 18 Mississippi State 31-24 and save the Tide's undefeated season. On the play before the touchdown - and facing a 3rd-and-15 - Hurts found Calvin Ridley over the middle for a 31-yard gain, just a split-second before Mississippi State's defense crushed the pocket.

''We did a good job of staying together, being one and staying cool and calm,'' Hurts said. ''We did enough.''

Alabama (10-0, 7-0 SEC, CFP No. 2) won its 10th straight game against Mississippi State, but this one was much more difficult than most of the others.

Mississippi State (7-3, 3-3, CFP No. 16) pushed ahead 24-17 early in the fourth quarter on Jace Christmann's 25-yard field goal, but Alabama responded to tie it at 24 when Damien Harris ran for a 14-yard score with 9:49 left. Alabama had a chance to take the lead with about two minutes left, but a 41-yard field goal attempt by Andy Pappanastos banged off the left upright and fell to the turf.

Mississippi State went three-and-out on the ensuing drive and Alabama took over with 1:09 remaining. That was more than enough time for the Tide, who drove six plays and 68 yards in 44 seconds for the game-winning score.

Hurts said he changed the play on the third down pass that went to Ridley. The star receiver was hesitant at first.

''I saw something in the defense, so I told him to run the route I wanted him to run,'' Hurts said. ''He kind of shook his head no at first, and I said, `Trust me, I got you.'''

Alabama coach Nick Saban wasn't particularly pleased with parts of his team - especially on defense - but he was relieved it responded well to some adversity.

''Sometimes you need hard,'' Saban said. ''If we're going to beat really good teams, if we're going to compete, we've got to learn how to compete in close games where every play counts. Where you've got to play every play for 60 minutes.''

The game was tight throughout with neither team leading by more than a touchdown. Mississippi State pushed ahead 7-0 in the first quarter on an 11-yard touchdown run by Aeris Williams. It was the first touchdown the Bulldogs had scored against Alabama since 2014 and the first time they'd taken the lead against the Tide since 2008.

Alabama's defense has been dominant for most of the season, but several injuries at linebacker throughout the season finally appeared to take a toll. Mississippi State's power running game gained 172 yards, but in the end Alabama was able to slow the Bulldogs down.

''It hurts,'' said Mississippi State quarterback Nick Fitzgerald, who threw two Hail Mary attempts to no avail in the closing moments. ''It doesn't matter who we lost to or how much we lost by, we lost a game we should have won.''

Mississippi State coach Dan Mullen - who is now 0-9 against the Tide - said he didn't regret the team's decision to try and put pressure on Hurts late.

''We are an aggressive defense,'' Mullen said. ''We came after them. That's our style. We are not going to charge our style or get conservative.''

THE TAKEAWAY

Alabama: The Crimson Tide found a way to survive arguably their toughest test of the season. Hurts completed 10 of 19 passes for 242 yards and a touchdown. Ridley caught five passes for 171 yards.

Mississippi State: The Bulldogs did just about everything right except for win the game. Fitzgerald completed 13 of 24 passes for 158 yards and ran for 66 yards and a touchdown. Williams ran for 97 yards and two touchdowns.

UP NEXT

Alabama hosts Mercer next Saturday.

Mississippi State plays at Arkansas next Saturday.

---

More AP college football: http://collegefootball.ap.org and http://www.twitter.com/AP-Top25 .

Copyright 2017 by STATS. Any commercial use or distribution without the express written consent of STATS is strictly prohibited.