Zach Abey is met behind the line of scrimmage by UCF’s Pat Jasinski. Abey later left the game. (Jonathan Newton/The Washington Post)

Navy Coach Ken Niumatalolo knows his team’s margin for error is slim. Because the Midshipmen recruit within the limitations of a military academy, odds are that the guys across the line of scrimmage are a little bigger, perhaps a little stronger. To make up the difference, Niumatalolo harps on the little things: Don’t commit penalties. Don’t miss defensive assignments.

On Saturday, Navy (5-2, 3-2 American Athletic Conference) made too many little mistakes, and No. 20 Central Florida took advantage to notch a 31-21 victory as Coach Scott Frost led the red-hot Knights to the first 6-0 start in program history in front of a homecoming crowd of 35,277 at Navy-Marine Corps Memorial Stadium.

The loss was Navy’s second in a row and snapped the team’s 17-game regular season home winning streak.

“We knew coming in we had to play a clean game,” Niumatalolo said. “We knew we couldn’t have foolish penalties, which we did, missed assignments, which we had. You have to try your best to limit all of those things. A team like that is too good. Even if you don’t have missed assignments, it will be hard to play those guys.”

The Midshipmen had even less wiggle room without starting quarterback and leading rusher Zach Abey, who was knocked out of the game in the third quarter after taking a hit to the head, and senior fullback and No. 3 rusher Chris High, who sat out the game with an undisclosed injury.

When senior slotback Darryl Bonner fumbled a pitch from backup quarterback Garret Lewis with Navy trailing the nation’s top offense by just three points early in the fourth quarter, it felt like a critical blow.

UCF quarterback McKenzie Milton promptly led a seven-play, 54-yard scoring drive. Otis Anderson provided the final margin when he sliced through a loose Navy defense for a 10-yard touchdown run with 3:30 remaining.

“They had the one-play drive right out the half that was like a 78-yard run, they had a long kick return to get in good field position, and at the end of the game, we had little gap-assignment mishaps,” senior linebacker Micah Thomas said. “They’re a great team, but I do think we beat ourselves a little bit.”

While Navy was working with Lewis, a junior who made his collegiate debut last week in a loss against Memphis and was on field for all of one play before Saturday, UCF (4-0 AAC) had one of the most precise quarterbacks in the country leading its attack. Milton ranks second in the nation behind Oklahoma’s Baker Mayfield in passing efficiency (203.6) and fourth in the nation in both completion percentage (70.3) and yards per completion (16.54).

On Saturday, he and running back Adrian Killins led a balanced offense that gained 247 yards rushing and 236 through the air. Milton completed 15 of 23 passes for 233 yards and one touchdown to balance his interception. Killins had 122 yards on 15 carries and ran for two touchdowns.

UCF’s defense did its part as well. Frost, a former option quarterback at Nebraska, spent the week before Saturday’s game playing his college position with the scout team to give his Knights the best possible preparation against the Midshipmen’s option offense.

They limited Navy to 419 yards — including 248 on the ground — nearly 150 below its nation-leading average.

Lewis completed 3 of 9 pass attempts for 56 yards and an interception, to go with 11 carries for 39 yards on the ground, after coming in on little preparation.

“Sometimes you’re just dealt a hand,” Lewis said. “It is what it is. . . . I was prepared to come in. I really just wanted to come in and execute to the best of my ability, and I wanted the offense to do well.”

Abey extended his program-record streak of 100-yard rushing games to eight before he was forced out. He finished with 25 carries for a game-high 126 yards and a touchdown and completed 2 of 4 passes for 115 yards, a touchdown and an interception.

The junior went down with just less than 10 minutes left in the third quarter after taking what looked like helmet-to-helmet contact on Navy’s second drive of the half. He appeared shaken walking off the field but returned and watched from the sideline for much of the fourth quarter.

Niumatalolo said after the game that he was waiting on the team’s medical staff to hear whether Abey has a concussion.

Lewis had Navy clicking for a period, after Abey set a slow but steady offensive pace against an aggressive UCF defense. Early in the fourth quarter, Lewis handed off to Anthony Gargiulo, the third-string fullback, for a seven-yard touchdown to cap a 10-play, 75-yard drive that included a 30-yard completion from Lewis to Bonner. The Midshipmen were within 24-21.

But on Navy’s next offensive sequence, Lewis pitched the ball to Bonner too late and Bonner fumbled — Lewis shouldered blame for the gaffe after the game — and the Midshipmen couldn’t swing momentum back in their favor.

They head into a bye week before facing Temple in Philadelphia on Nov. 2.

“We tried to out-effort them. That’s how we play,” Thomas said. “We’ve just got to play harder, play smarter, and we can’t beat ourselves. That’s what we say every week. That goes to show, if we beat ourselves, the other team will score.”