DURHAM — Just when the Londonderry High School football team looked like it was in trouble, the Lancers wiggled free.

Londonderry trailed Exeter by three points midway through the fourth quarter of Sunday’s Division I championship game, but the Lancers scored 14 points during a span of 4:28 in the final quarter and captured the Division I championship with a 21-10 victory at the University of New Hampshire’s Wildcat Stadium.

First quarterback Jake McEachern scored on a 1-yard run with 7:09 to play, then, after Exeter fumbled the ensuing kickoff, the Lancers added to their lead when Tyler Kayo scored on a 2-yard run with 2:41 remaining. It was only the second fumble Exeter had lost this season.

McEachern ran for a game-high 112 yards and two touchdowns on 20 carries, including a 41-yard gain on a fourth-and-3 play from the Exeter 49 that set up his go-ahead TD.

“We’ve been working all season for this,” McEachern said. “It’s just a great feeling. We had to dig in and just stay within ourselves to finish the game on top. It was really a dogfight. They do have a great program.”

The victory capped an unbeaten season for Londonderry (12-0). It was the program’s first state championship since 1998, when Londonderry beat Concord 33-7 for the Division I title.

“For 11 games we didn’t deal with any adversity, really,” Londonderry coach Jimmy Lauzon said. “We didn’t trail in the second half all year. It did happen in the second half, but we’ve been preaching it so much. We’ve been ready for it. Our motto this year has been, ‘Get comfortable with the uncomfortable.’ We just kept telling them that and they were fine. They dealt with it.”

Exeter (10-2) trailed 7-3 until halfback Jaedon Cliche found the end zone on a fourth-and-goal play that began just inside the Londonderry 3-yard line. Nolan Elmore’s point-after kick handed the Blue Hawks a 10-7 lead with 10:29 to play. As Lauzon pointed out, that was the first time the Lancers trailed after halftime this season.

Derek Edmiston led Exeter with 45 yards rushing on 14 carries. Spencer Clark added 43 yards on 11 attempts; quarterback Ryan Grijalva ran for 41 yards on eight carries; and Jaedon Cliche picked up 39 yards on nine carries.

The Blue Hawks turned the ball over three times.

Exeter opened the scoring on Elmore’s 26-yard field goal with 4:44 remaining in the first quarter.

Londonderry had only two possessions in the first half, but scored on its second one when McEachern snuck in from a yard away with 52 seconds remaining in the first half. Zach Fawcett’s point-after kick gave the Lancers a 7-3 lead, which is how it stood entering the final 12 minutes.

Londonderry entered the game as the No. 1 team in the Union Leader Power Poll. Exeter was No. 2.

Exeter was seeking its first state championship since 2012, when it won the second of back-to-back Division I championships. The Blue Hawks also lost in the 2015 and 2016 Division I championship games.