STANDISH — It wasn’t until 8.3 seconds remained and Bonny Eagle held a five-point lead that the home fans began to chant, “It’s all over.”

The Scots were glad to hear it at all.

Bonny Eagle built a 17-point lead by halftime, but South Portland fought back and fell just short as the Scots held on for a 64-57 victory in an SMAA boys’ basketball game Tuesday night.

Ben Malloy scored 24 points and Zach Dubiel had 18, including five 3-pointers, to help the Scots (4-2) bounce back from a 55-43 loss Friday night at Westbrook.

“We came out soft against Westbrook and got into a 22-point deficit, so we knew we had to come out strong and beat the level of intensity they were going to bring,” Malloy said. “Defensively, got physical with them, which you have to when you give up size like that. We had good help-side defense and we boxed out well.”

That’s for sure. Bonny Eagle outrebounded the Red Riots 19-11 in the first half.

“We did a really nice job boxing out and not letting them get second-chance shots,” Bonny Eagle Coach Phil Bourassa said. “We had to dig deep in the second half and just make our shots.”

The Riots (4-2), meanwhile, struggled.

“We didn’t come ready to play and the game was won by their first-half run,” Coach Phil Conley said. “I was very disappointed we didn’t come ready. That won’t happen again this year.”

That changed just after halftime. The Riots started to get the ball to their 6-foot-5 big men, Jaren Muller, who had 17 of his 19 points after the break, and Jack Fiorini, with 12 of his 16.

“Our kids battled back and it was a two-possession game with about two minutes to go,” Conley said. “That’s the way I expect my kids to play.”

The Riots chipped away, taking advantage of Malloy’s exit after his fourth foul, outscoring the Scots 20-12 to close to 41-32 after three periods. Malloy returned with 32 seconds left in the third.

“We knew South Portland’s a great shooting team and they can come back on anyone,” Dubiel said.

For much of the final period, South Portland had momentum.

That is, until Dubiel got the ball. After the Riots pulled within 41-34 with 6:37 left, Dubiel stood on the wing, took an inside-out feed from Malloy and hit the first of three 3s in the quarter.

Riding the rebounding of 6-5 Ruay Bol and the frenetic defense of Kam Harper and Silas Zechman, South Portland cut it to 45-40 and called a timeout with 5:45 to go. Malloy drove the lane and hit two free throws for a nine-point cushion. Muller scored off the glass to make it 49-42, then Dubiel hit another 3 to push the lead back to 10. In the closing minutes he hit his third 3 to make it 57-48.

“Those gave us a big momentum spark, got his confidence up and got the crowd into it,” Malloy said.

“Zach finds these spurts,” Bourassa said. “They were very timely. I tell the kids when you’re feeling it, I’m not going to stop you. He was feeling it.”

And his rhythm restored much-needed breathing room.

“We made enough shots to get by,” Bourassa said. “And we got it done.”