Portland High had to work harder and longer for Maine’s first-ever Class AA boys’ basketball title than anyone expected. Except, apparently the team from South Portland.

The Bulldogs (20-1) won Class AA boys’ basketball state championship game Saturday against South Portland, 52-50 in double overtime, at the Cross Insurance Arena. It wasn’t over until one last effort by South Portland with 0.2 seconds lefts.

The game ended with South Portland’s Deandre White taking two free throws with 0.2 seconds. White made the first and missed the second on purpose, but South Portland could not get a tying tip.

Portland senior Amir Moss, who pointed out on the first day of practice he’d never lost a game at Portland’s civic center, did a lot to make sure it he didn’t lose his final game there. Moss scored the go-ahead basket after a Jack Fiorini 3-pointer had given South Portland its final lead. He finished with 27 points, 11 rebounds and a key assist to his brother Terion in the second overtime.

“I think we all made sure that wouldn’t happen,” Moss said. “It felt great to keep that winning streak here and felt magic to win that state championship here.”

“We were kind of struggling there at the offensive end and we just kept giving Amir the ball,” Portland Coach Joe Russo said.

But it was Amir’s miss of the front end of a one-and-one with 6.6 seconds left that gave South Portland a final chance.

The ball caromed about the court and was nearly lost when a diving Riley Hasson was fouled near midcourt. Hasson had been on the court and involved in collisions repeatedly only to pop up, inspiring South Portland to keep scrapping.

This time Hasson struggled to get up and White took his place for the free throws. White’s intentional miss just grazed the front of the rim and caromed away from South Portland potentional tippers Fiorini (12 points) and Ruay Bol (14 points).

South Portland – a team that was a lackluster 9-9 in the regular season – never backed down and was in position to upset Portland, especially after Hasson opened the second overtime with a 3-pointer to give his team a 46-43 lead.

“They’re winners, they really are,” South Portland Coach Kevin Millington said. “It took just took us awhile to figure each other out at the beginning of the year. They’re just winners I think. But so is Portland.”

Portland (20-1) entered the game with an edge in championship game experience. The Bulldogs were playing in their third straight state final and sixth in Coach Joe Russo’s 25 seasons at the helm.

South Portland (12-10), in Millington’s first year on the sideline, was making its first trip to a state final since losing the 2013 Class A final to Hampden. The Red Riots last title came in 1992 – a five-overtime classic against Bangor.

Portland beat South Portland twice by sizable margins in the regular season (75-56 at home; 68-38 in South Portland).

“We didn’t think about those games at all,” Fiorini said. “We knew we had mistakes and we just worked to fix them. We just made sure those were points of emphasis but we never really looked back at the score. We just knew that we were a different team.”

The first half was not fluid for either team, in large part due to South Portland’s willingness to dive on the floor, crash into the media table (Hasson) and just generally compete with the Bulldogs.

Portland lead 22-16 at halftime, with Amir Moss scoring nine points and sophomore Griffin Foley adding eight. He and Moss hit back-to-back 3-pointers to give Portland a 17-12 lead with 5:36 to play.

When Moss pushed his way through South Portland’s inside size for a basket for a 20-12 lead it felt like South Portland could have been on the ropes. Instead, Bol finished twice at the rim, the second an athletic effort after a hustling steal and pass from Hasson.

Portland led 31-28 after three. Matt Pelletier (12 points) tied the game early in the fourth with a 3-pointer and neither team led by more than 3 the rest of the way.