Navy quarterback Malcolm Perry scores a touchdown in the third quarter of Saturday’s 43-40 win over SMU in Annapolis. (Patrick Smith/Getty Images)

There wasn’t much confidence left on the Navy sideline by the time J.R. Osborn, the sophomore place kicker who only recently had worked his way up to traveling with the Midshipmen, lined up for an 18-yard field goal with the game on the line.

The Midshipmen had been through the wringer Saturday at Navy-Marine Corps Memorial Stadium: They had seen Malcolm Perry, the sophomore who had started every other game this year at slotback, instead start under center for the first time in his career and rush for a dazzling 282 yards, only to sprain his left ankle late in the fourth quarter and leave the field on crutches. They had watched as a 23-point halftime lead over Southern Methodist shrank to zero.

When Osborn’s kick sailed through for a 43-40 win, the beaten-up and tired Navy players took off their gold helmets and celebrated in the middle of the field, a moment that looked like release.

“It’s pretty euphoric,” right guard Evan Martin said.

Behind Perry’s heroics and Osborn’s clutch kick, the Midshipmen (6-3, 4-3 American Athletic Conference) beat SMU on senior day to become bowl eligible for the sixth consecutive year and 14th time in the past 15 years. Navy also snapped a three-game losing streak and got back to playing like itself again — and not a moment too soon. Next week the Midshipmen play No. 3 Notre Dame in South Bend, Ind.

Navy fullback Anthony Gargiulo breaks free during Saturday’s Midshipmen win over Southern Methodist University. (Patrick Smith/Getty Images)

“We were holding on for dear life,” Navy Coach Ken Niumatalolo said, “we started to sputter on offense, and I just felt like if we could keep scoring and take care of the rock, then we’d have a shot. But to be bowl eligible again, for this many years, it shows the consistency of our program.”

Niumatalolo made a major personnel change to snap Navy back into shape. He started Perry, the speedster who saw time at quarterback in two games last year but had not played the position since spring ball, over first-string quarterback Zach Abey and backup Garret Lewis because he wanted to jump-start the Midshipmen.

His plan worked. Before his injury, Perry had four touchdowns, including on runs of 92 yards — the second-longest touchdown run in program history — and 24 yards. His 196 yards at halftime were the second most in school history amassed in one half. Perry flaunted not only his speed but his elusiveness, and he led the Mids to a 34-11 lead at halftime.

“That’s God-given,” Niumatalolo said.

Abey, who injured his left, non-throwing shoulder in a Nov. 2 loss at Temple, watched from the sideline. Niumatalolo said Abey could have played in a pinch and will be available if Perry is unable to go against Notre Dame.

It was in that loss in Philadelphia that Niumatalolo decided he would start Perry instead of Abey this week against the Mustangs.

“I just feel like he’s our best ballcarrier. We needed a spark,” Niumatalolo said. “We were sputtering on offense, and I just wanted to see if he could give us some life. We took a chance — he hadn’t played quarterback since the spring, but he has the best quarterback coach in [offensive coordinator Ivin Jasper]. . . . Ultimately, I had to do what I felt was best for our team.”

Navy kicker J.R. Osborn blasts the game winning field goal for the Midshipmen at the end of a thrilling victory over SMU on Saturday. (Patrick Smith/Getty Images)

Navy rushed for 559 yards and averaged 7.7 yards per play, far above the 5.1 yards per play it has averaged over the past three losses. Navy only bothered to throw once, and Perry’s lone attempt resulted in an interception.

Supporting Perry on offense was junior fullback Anthony Gargiulo, who broke runs of 21 and 29 yards to key the Mids’ 10-play, 78-yard drive that set up Osborn’s kick as time expired. Saturday’s game included firsts for both players: Gargiulo rushed for a career-high 145 yards. Osborn’s field goal was his first career attempt at a scoring kick.

“I still really don’t know what’s going on or what’s happened,” Osborn, who filled in for the injured Bennett Moehring, said afterward.

Navy’s defense did its part to support Perry in the first half, holding SMU (6-4, 3-3) to 173 yards of total offense before intermission while the Mids racked up 357. But the Mustangs’ offense reloaded after halftime and scored on all three of its possessions in the third quarter while Navy faltered.

On SMU’s final drive of the third quarter, Navy safety Sean Williams was called for targeting. The penalty comes with an ejection and also means the Mids’ top defensive back will miss the first half of next week’s game at Notre Dame. Mustangs wide receiver James Proche grabbed a 17-yard touchdown pass two plays later to shrink Navy’s lead to 40-32, and to twist the knife, senior linebacker D.J. Palmore was called for roughing the passer on the final play of the series. The penalty put SMU on the 50 for kickoff.

The eight-point margin held until SMU’s final drive, which covered 71 yards in five plays and was sealed with Ben Hicks’s 29-yard pass to Courtland Sutton. The Mustangs completed the two-point conversion to tie it at 40 with 3:32 remaining, setting the stage for one final piece of drama.

“We got tough kids,” Niumatalolo said. “We’re going to fight to the end. I’ve been telling people — we’re going to fight to the freakin’ end.”