BANGOR, Maine — The Camden High School girls soccer team turned the tables on the Bangor High School girls Wednesday night.

The Windjammers, who surrendered two goals in the final 17 minutes of last year’s one-goal Class A North championship game loss to the Rams, scored twice in the final 3:49 to stun the Rams by the same score, 3-2.

It is Camden Hills coach Meredith Messer’s first regional title in her 21 seasons at the school, and it came in their second year in Class A after moving up from Class B.

Camden Hills (16-1) plays 16-0-1 Gorham in the state championship game at 3 p.m. Saturday at Fitzpatrick Stadium in Portland.

Defending state champ Bangor wound up 16-1 and had its 27-game unbeaten streak snapped (25-0-2).

Camden Hills was the last team to beat Bangor — 4-1 on Sept. 22, 2015.

Speedy freshman striker Kristina Kelly tied it with 3:49 left after making a scintillating dash down the left wing, and Izzy Gutheinz scored the game-winner just 39 seconds later.

Second seed Camden Hills had a sizeable edge in possession, attempted 27 shots to Bangor’s nine and spent much more time in Bangor’s half of the field.

But the Rams defended admirably and used restart goals from Katie Butler off a corner kick and Bella Varisco from a free kick to sandwich Charlotte Messer’s penalty kick and take a 2-1 lead in the intermission.

“I kept glancing back at the clock, and there was less and less time left,” said senior midfielder Gutheinz. “We knew we had to get it done. It helped that we all had positive energy. We went to every ball as hard as we could, and Kristina’s goal gave us even more energy.”

Kelly picked up the ball at midfield and found a ton of open real estate ahead of her. She sped down the wing, took the ball wide on a Ram defender and then sliced across the goalmouth before rifling a 7-yarder into the far corner for her 32nd goal of the season.

“There was one defender, and I decided to go to my left in case I kicked it too far. I didn’t want the goalie to get it,” said Kelly. “I cut to the right, and there were four defenders coming over, but my parents have coached me to shoot it early, and that’s what I did. The goalie [Maddie Hodgdon] was at the near post, so I shot it far post.”

Just seconds later, Kelly fed the ball across to the top of the penalty area to Kassie Krul, who slid it over to an open Gutheinz on the right side.

“I took a touch and gave it my best shot,” said Gutheinz, who sailed her 18-yarder into the far-side corner. “I looked up and saw that lane [to the far post]. I hope it would go there.”

Isabelle Lang made three saves on nine shots, and Hodgdon wound up with nine saves on 27 shots.

An unmarked Butler opened the scoring by nudging home Megan Conner’s corner kick, but a handball off a Windjammer corner enabled the dynamic Messer to equalize from the spot.

Varisco made it 2-1 by sailing a 30-yard free kick into the upper left corner.

Bangor had a few forays into the Camden Hills penalty area in the second half, and both Luci Clein and Butler came close to extending the lead.

But Camden Hills’ perseverance paid off.

“It was a little frustrating to have so much possession but have unlucky bounces and unlucky shots. It kind of fueled us because we knew if we possessed the ball enough, the chances would come,” said Gutheinz.

Meredith Messer said the fact they played their semifinal on Saturday and Bangor couldn’t play until Monday because of rain was advantageous.

“We had fresher legs, but Bangor did a nice job defending. They didn’t give us very many lanes,” said Messer.

“They’re a good team. We tried to take their possession game away, and we did a real good job until the final four minutes,” said Bangor coach Joe Johnson.