LEWISTON — The dream of an undefeated season and state championship ended with three seconds remaining in the regional final Wednesday night.

Avery Lutraykowski one-timed a perfect pass from Isabelle Frenette to give St. Dominic a 5-4 win over previously unbeaten Greely in the North girls’ hockey championship game at the Colisee.

Greely (19-1) had given St. Dom’s (18-2) its only two losses.

The Saints will play Scarborough (18-1-1) for the state championship at 7 p.m. Saturday at the Colisee.

The Red Storm and St. Dom’s, who didn’t meet in the regular season, will each seek a second state championship. Scarborough has reached the final twice before, winning in 2014. The Saints’ one appearance in 2011 was a winner.

Greely, which won in 2012 and 2013, was seeking an unprecedented third state title. The Rangers looked like they might have a chance, especially after grabbing momentum in the final minute. Greely had pulled its goalie and Emilee McGillicuddy tied the game with 43 seconds left.

But Frenette, who already had scored twice, came around the Rangers’ net and found Lutraykowski in the left circle.

“It was a team effort,” Lutraykowski said. “The defense passed it up to (Frenette) and she came down and passed it over, and I just hit it in.

“It was coming down to the last few seconds. All I thought about was getting it in.”

The goal sent the partisan St. Dom’s crowd into hysterics while the Greely helmets dropped.

“We had a great season,” Greely Coach Nate Guerin said. “It’s very painful to lose this game in this manner.”

Greely beat St. Dom’s twice in January, 2-1 in Falmouth and then 8-4 in Auburn two weeks ago.

When Danita Storey’s two goals gave Greely a 2-0 first-period lead, the Rangers looked on their way to a third win.

But this was a different Saints team, which had dominated other opponents until facing Greely. In a way, those regular-season losses helped St. Dom’s mature.

“We knew what it felt like to be down,” said Lutraykowski, one of the eight freshmen on this 15-player roster, which which includes four sophomores.

Lutraykowki, who had two goals and two assists, missed the last Greely game because of a concussion. But it wasn’t just her return that made the difference, but a better team effort.

“They jelled as a team,” Saints Coach Paul Gosselin said. “They learned more team defense. At the beginning of the year we were putting up goals left and right, and we weren’t challenged a lot.

“Once we played stronger teams, we saw the weaknesses we had and worked on them.”

Guerin noticed.

“That was the best game they’ve played all season and they did it at the right time,” he said.

Frenette’s two goals early in the second period tied the game. Lutraykowski then came up big with a breakaway goal at 14:34 for a 3-2 lead.

Greely defenseman Ellie Schad took 20 seconds into the third period to tie it with her wrister.

St. Dom’s got the next break with the game’s only power play. Alexandra Hammerton buried a back-door pass from Lutraykowski at 12:26.

Then came the wild finish and the Saints’ celebration.