The boys basketball rivalry between Marshwood High School and Sanford has heated up these last two years, partly because they’re so evenly-matched and partly because they keep meeting in the first round of the Western Maine Class A playoffs.

On Tuesday night, when guard Alex McLean’s game-tying 3-pointer hit the back rim and bounced away, it was the eighth-seeded Hawks who had to make peace with heartbreaking defeat.

McLean’s attempt was the second of a pair of late 3-point tries that could have tied the game. Instead, it was the visiting Spartans who got to celebrate a come-from-behind, 52-49 win.

“We had some good looks at the end,” said Marshwood coach Mike Zamarchi. “I’m proud of my kids. They didn’t panic when things went bad. They kept playing hard.”

Ninth-seeded Sanford (11-8), which split two close games against the Hawks during the regular season and lost a close one here in last year’s prelims, advances to the regional quarterfinals at the Portland Expo on Friday night, where it will play top-seeded South Portland (15-3).

“We’ve played Marshwood six times over the last two years,” said Sanford coach Paul Nolette. “Last year’s prelim was the same exact thing; the roles were just reversed. It’s one of those close games where everyone knows what everyone else is doing. It’s like being in the same conference in football.”

Each team had a clear strategy. The Hawks (9-10) wanted to get the ball inside to 6-foot-6 center Brady Innes (14 points), giving him close-in chances and freeing up perimeter looks when the defense collapsed.

The Spartans wanted looks for senior off-guard Ryan Camire, a 22-points-per-game scorer who entered the game with 989 for his career.

The Hawks used their 3-point shooting to build a little early separation, with big man Innes bringing the big crowd to life by hitting a trey on his team’s first possession. Danny Veino and McLean followed suit.

The lead grew to 26-18 after Dodge hit a jumper in transition midway through the second quarter. But Innes was slapped with his third foul shortly after that, paving the way for the Spartans to go on a 7-1 run and climb back in.

The last two possessions of the half swung the momentum back to Marshwood. First, reserve guard Dylan Hamm got free inside to make it 32-27. Then, the defense hounded Camire (17 points) on the right wing for the final 10 seconds, preventing him from getting a shot off, with Zamarchi jogging off the floor shaking his fist after the horn sounded.

But the third quarter began unraveling just 23 seconds in, when Innes got whistled for his fourth foul and was pointed to the bench. Minus their inside edge, the Hawks struggled, managing just four points in the frame and chasing a 41-36 deficit to the fourth.

“Really hurt us,” said Zamarchi. “The last couple games he’s really been picking his game up, and he’s played really well against (Sanford) the last two years.”

A Camire 3-pointer late in the frame gave the Spartans their first lead of the night, 37-36. It also pushed him over the 1,000-point mark for his career; the game was stopped briefly to acknowledge the feat.

Their lineup intact to start the fourth, the Hawks began chipping away. McLean went up for an offensive rebound, got fouled and hit a free throw to square things 46-46 with less than four minutes to play.

Marshwood found itself down by one in the final minute but fouled Camire, who hit both tries with 36 seconds left. Dodge (11 points) drove and hit a pull-up at the other end to make it 50-49, but it was again Camire getting fouled and making both to keep his team up three.

“Give them credit. He wants the ball,” said Zamarchi, who would have preferred his players foul anyone else. “We tried to keep him from getting the ball. But he got to it.”

After Alex Shain missed the front end of a 1-and-1 with 7 seconds left, the Hawks had one final try. McLean pushed the ball up the left side and let go a runner that would have tied the game at the buzzer. It missed and the Spartans stormed the floor.

“Last year (in this game) we kind of lost our composure late,” said Nolette. “This year we didn’t.”

Not much separated these two teams this winter. But one is heading on to Portland while the other’s all done.

“It’s been our Achilles’ heel a little bit, that third quarter,” said Zamarchi. “Brady picking up his fourth was a key part of it. They were having trouble matching up with him.”