The rain didn’t really start coming down in Annapolis until there was just over 12 minutes left and the score was knotted at 28, but if Malcolm Perry had any say in the matter, neither rain nor wind nor bone-chilling cold would get in the way of senior day for him and his classmates.

The group, all 32 graduating seniors, had been through enough at the Naval Academy: last year’s 3-10 season of dread, three straight losses to Army and a pair of defeats to Air Force. Perry and his classmates’ goal this season has always been to make up for all of that hurt and leave with a favorable legacy.

They took another step in the right direction Saturday with a 35-28 win over SMU, a victory that kept the Midshipmen in contention for a spot in the AAC title game Dec. 7 and that was their 17th in a row on senior day.

Navy (8-2, 6-1) must beat Houston on the road next Saturday and Memphis, ranked No. 18 in the College Football Playoff rankings, must lose to No. 19 Cincinnati on Friday for the Mids to play in the conference championship game.

“This was a championship game. For us to be playing in a championship-elimination game in late November speaks volumes to where we want to be as a football program,” Navy Coach Ken Niumatalolo said before crediting his senior class with turning around the program after last season. “We met back in January when we came back after Christmas break, and I could just look in those guys’ eyes and they said: ‘Coach, that’s not going to happen again. We’re going to be the class that turns the ship right.’ And they were serious.”

It was Perry’s 70-yard touchdown with just over six minutes to play that put the Mids ahead for good and a handful of critical plays that kept them there — a dropped pass on third down on SMU’s ensuing drive, a big stop on fourth and four from the Navy 12-yard line thanks in part to junior cornerback Cameron Kinley, and an offside call on fourth down that gave Navy an automatic first down and ended the game.

“That was for the seniors right there,” Kinley said.

All told, Perry, a senior quarterback from Tennessee, rushed for 195 yards on 28 carries and two touchdowns. He completed a career-high 9 of 15 passes for 162 yards and threw for another score. Navy outgained the Mustangs 540-344 even as former Texas quarterback Shane Buechele completed 16 of 28 passes for 251 yards.

It was Niumatalolo’s fifth win against a Top 25 team in his 12 years as coach and Navy’s first win against a ranked opponent since October 2016; SMU (9-2, 5-2) sits 25th in the CFP rankings and 21st in the Associated Press poll.

“We kind of put everything on Malcolm’s shoulders. He actually told me at one time, ‘Coach, you’ve got to give me a break, man; give somebody else the ball.’ I was like, ‘Hey, suck it up; we need you.’ I didn’t realize he carried the ball 38 times,” Niumatalolo said, laughing.

SMU arrived in Annapolis rested, coming off an open date. Navy was yearning for redemption after absorbing a 52-20 beating at Notre Dame last week.

The Midshipmen landed the first blow, a 22-yard touchdown run by Chance Warren, but the Mustangs’ reply was immediate: Senior CJ Sanders ran back the ensuing kickoff 100 yards to tie it at 7.

After a 41-yard field goal by Navy’s Bijan Nichols early in the second quarter, Buechele and his offense remained unflinchingly precise as SMU’s defense dialed up the intensity. The Mustangs sacked Perry on back-to-back plays and led 21-10 with 4:01 left in the half before the Mids found their focus in the third quarter — a shaky start Niumatalolo attributed to the emotion of senior day.

Perry finally got going and led the Mids through a dominant period in which they gathered 211 yards to the Mustangs’ 4. He ran in a one-yard touchdown for the first score of the quarter and got Navy within field goal range to narrow SMU’s lead to 21-20 on Nichols’s 24-yard kick.

He turned in a final 17-yard run before the end of the quarter, shaking off a few hands grabbing at his jersey along the way, to get to the SMU 13-yard line. Perry finished the drive early in the fourth with a 13-yard pass to Ryan Mitchell for a touchdown, then tossed a lob to CJ Williams for Navy’s first two-point conversion of the year.

But just as they did when threatened in the first quarter, the Mustangs had an immediate response. Buechele took just over two minutes to rattle off six plays, ending with a screen to wideout Rashee Rice — who took off up the left sideline for a 61-yard touchdown that tied the score at 28 and set up Perry’s final star turn of the day.

The quarterback appeared at the postgame news conference with a newly shaved head. Navy’s seniors found out their service assignments this week: Perry and 13 of his classmates were assigned to the Marines.

“We had run the play a couple times before, kind of got a feel for how they were playing it, expected them to do what they did, made some great blocks, and I was able to get in the open field and make a touchdown,” Perry said.

Said Niumatalolo: “I heard somebody say, ‘When you get into these kinds of games, think players, not plays’ — and all I could see was No. 10 in my head. He’s going to carry us. . . . We put our whole team on Malcolm’s back, but he’ll have some rest tomorrow.”

Read more from Post Sports: