AUGUSTA — Riley Robinson went to the foul line four times. The first two free throws, with 15.6 seconds left, set his team up for victory. The final two, with 4.7 seconds to go, sealed it.

Robinson scored 12 of his 23 points in the fourth quarter to help Dirigo top Old Orchard Beach 50-47 in a Western Class C boys’ basketball quarterfinal Monday at the Augusta Civic Center.

Third-seeded Dirigo (18-1) advances to a regional semifinal against No. 2 Waynflete at 7 p.m. Thursday at the Augusta Civic Center. Waynflete (16-1) advanced with a 78-47 win over No. 10 Monmouth Academy.

Joe Gildard led the Seagulls (14-5) with 10 points. Anthony Langella-Laws finished with nine points and eight rebounds. Quincy Grace had nine points and six rebounds in limited action because of foul trouble.

“(Robinson) was very strong for us, but the biggest thing he did tonight was go 4 for 4 at the end,” said Dirigo Coach Travis Magnusson, whose team outscored OOB 21-12 in the fourth quarter. “It’s a tough situation for a freshman, but he knocked them down. He was very cool. I don’t think the ball hit the rim.”

It was a cool finish to a hotly contested game that was back-and-forth from the start. Early foul trouble took Grace, OOB’s 6-foot-3 big man, out of the game in the second quarter. Just when Dirigo looked to be edging away, leading 20-15 with 3:55 left in the first half, Zach Seamans hit two layups during a 6-2 run by the Seagulls that cut it to 22-21 at halftime.

“OOB played really well, and they did most of it without their big guy,” Magnusson said. Not having to face Grace “was kind of a wash for us, because the guys who came on played really well. I feel like we kind of stole one today.”

Old Orchard Beach came out strong in the second half, as Langella-Laws — easy to find by his play as much as his Mohawk haircut and pink socks and sneakers — hit two consecutive 3-pointers to help the Seagulls to a 29-22 lead two minutes into the third. Robinson answered with a shot from the baseline and another short jumper to close it to 31-26, and the seesaw battle was on again.

“This is a good win. We didn’t play well at first, but we stuck around,” Robinson said. “We gutted it out.”

Grace hit from the low post to make it 45-41 in favor of OOB with 3:20 left. Robbie Babb (nine points) responded with a basket for Dirigo, then made one free throw before Robinson’s basket with a minute left put the Cougars ahead for good, 46-45.

Robinson then sank two free throws to make it 48-45. Grace scored again before Robinson went to the line again time.

“I was feeling good,” Robinson said. “You’ve got to be confident stepping up to the line in that situation. My teammates were really supportive. They wanted the ball in my hands. They trusted me.”