LEWISTON — The sight of two teammates losing their singles matches a few courts over pulled Carter Brock and Matt Galvin of Cape Elizabeth out of their early lethargy.

“That woke us up,” Brock said. “It meant we mattered.”

Inspired, Brock and Galvin rallied to a three-set victory at second doubles to set the stage for a Class B South boys’ tennis title Thursday on the blustery courts of Bates College.

Third-seeded Cape Elizabeth edged No. 5 York 3-2 after Michael Mills pitched a shutout at No. 1 singles on the heels of a 1-6, 6-4, 6-3 win by Brock and Galvin that tied the match at 2-2.

The Capers (13-2) will seek a fourth straight Class B state title Saturday against Camden Hills (14-1) at Lewiston High.

In other South finals Thursday, No. 1 Thornton Academy ended No. 2 Falmouth’s two-year Class A state title reign with a 3-2 win delayed by rain and completed indoors at Bates, and in Class C South, No. 4 Waynflete swept No. 3 Hall-Dale, 5-0.

The other state finals Saturday pit Thornton Academy (15-0) against Lewiston (12-3) in Class A and Waynflete (13-2) against George Stevens Academy (13-2) in Class C.

Cape Elizabeth beat York (8-7) twice in the regular season without dropping a match but this time faced a fully healthy lineup. Dinon Hughes (3-6, 6-0, 6-1) and James Peter (6-3, 6-4) of York won at second and third singles to take a 2-1 lead after Cape Elizabeth opened with a 6-4, 6-0 victory at No. 1 doubles behind Declan McCormack and Wyatt Newhall.

“I think we came out with a bad mindset,” said Galvin, one of the five newcomers to the Cape Elizabeth starting lineup. “We were like, ‘We’re second doubles. Everybody else can take care of it.’ Then we started putting Cape in our minds instead of just us.”

After losing 6 of 7 games in the first set, Brock and Galvin trailed 4-3 in the second to Thomas Donnelly and Ben Duffy of York before turning things around.

“In this venue, sometimes it gets a little overwhelming,” Capers Coach Andy Strout said. “It’s first time, big time. They played some matches last year but nothing that meant so much as this one.”

In Class A, Falmouth (14-1) was without its top player, freshman Nick Forester, who injured his knee in the semifinals of the state singles tournament. His opponent that day, Thornton freshman Dariy Vykhodtsev, decided Thursday’s regional final with a 6-1, 6-2 victory over Alex Klemperer of Falmouth.

The teams split doubles matches outdoors, before a 27-minute rain delay moved the remaining singles matches indoors. Viktor Schwarz of Thornton completed a 6-0, 6-3 victory at No. 2 singles but Falmouth stayed alive when Matt Adamowicz rallied to win 1-6, 6-3, 6-3 at No. 3 singles.

Waynflete, which also won the Class C South sportsmanship award, swept singles behind Brandon Ameglio, Peter Michalakes and Shuhao Liu, with Liu rallying to a 5-7, 6-4, 6-3 victory at No. 3.

“That’s the first time we’ve taken a set off Waynflete,” said Hall-Dale Coach Dan Bence, whose team was eliminated by the Flyers for the third straight year and fourth time in seven years.

Waynflete dropped only three games in each of the two doubles matches, with Thonne Kieffer and John Van Dyke winning at No. 1, and Rowan May and Cooper Sherman winning at No. 2.