Suddenly, a night full of drama and a game full of heroics handed the script to the most deserving story of all.

Carson Beck’s journey hasn’t been easy. He ended last season injured and dumped by Georgia. He signed with Miami and started the summer with his surgically repaired elbow under recovery.

Thursday night, Beck threw Miami down the field on its final drive when the night demanded it, and then took off running 3 yards into the end zone with 18 seconds left when the win needed that, too.

“The best feeling I’ve had in my life,’’ he said after Miami’s 31-27 win against Mississippi.

He found a home this season.

He’s coming home again now, too. They all are for the college championship game on Jan. 19. Miami will play in Hard Rock Stadium against coach Mario Cristobal’s former team, Oregon, or against Indiana and hometown Heisman Trophy winner Fernando Mendoza.

What a night this was. What a win. What a classic fourth quarter to cap not just Beck’s journey but Miami’s full odyssey back from nowhere to the biggest stage of all in college football.

How long was it since Miami played in a game with these stakes?

Twenty-three years?

Now this program gets a chance at another one after a night where for so long Miami seemed to dominate but couldn’t pull away. Pick your favorite stat to show that. Miami had the ball for 23 more minutes than Mississippi. It ran 28 more plays than Mississippi. It was 13 of 21 on third- and fourth-down conversions to Mississippi’s 2 for 10.

It had the makings of a blowout even by halftime by any number but the ones that matter most. Miami only led 17-13.

Mississippi kept doing just enough to stay in it. Miami did just enough not to completely take it, too.

Untimely penalties. Nibbling breakdowns. And the fact Mississippi’s first good play of the game on the opening play of the second quarter had star running back Kewan Lacy bust loose for a 73-yard touchdown run.

Mississippi became an oddly heartwarming story these playoffs when coach Lane Kiffin split for rival LSU and the team kept winning. Their anything-it-takes approach made them the darling of these playoffs in the manner Miami never could be.

Miami is just the team Cristobal wants, though. Built on physical lines. Able to run the ball and stop the run. And strong? Did you see how Miami responded with Thursday on the line?

There were three lead changes in five minutes of the fourth quarter. There were Miami heroics of receiver Malachi Toney turning a short pass into a 36-yard touchdown for the lead, and Mississippi’s answering heroics of quarterback Trinidad Chambliss throwing a 24-yard touchdown to retake the lead.

Finally, there was Beck. He’s an oddly discussed player in college football. He’s doubted in way others aren’t. He’s been around long enough to have a known portfolio.

But there wasn’t much to doubt how he played with the season up for grabs Thursday. He converted seven third downs into first downs this game. None was bigger than his facing third-and-10 and throwing to Keelan Marion over the middle for 18 yards. Earlier, he had thrown a 52-yard touchdown to a wide open Marion.

On this final drive, Beck didn’t find anyone wide open. His throws needed to be perfect. There was no margin left in a game where Miami’s 10 penalties for 74 yards showed there are some parts still to clean up.

Beck missed some throws early, as he said afterward. He made up for it on this final drive in the second half. He passed on third-and-6 to CJ Daniels for 7 yards. Another third-down pass resulted in a Mississippi coverage penalty.

The final play, the one he ran in from the 3, didn’t require much thought.

“I saw the end zone open to me,’’ he said.

Now Miami ends the season, one way or the other, at home in the championship game.