CAPE ELIZABETH — Fifth-seeded Scarborough won the first set, nearly pulled out the second, then captured the next two to end Cape Elizabeth’s reign as the volleyball state champion with a 3-1 victory in a semifinal Wednesday night.

Scarborough (12-5) will play second-seeded Greely (13-3) for the Class A state title at 1 p.m. Saturday at South Portland High. The Red Storm will seek their first title in their third trip after losing to Falmouth two years ago and to Greely in 2011.

In a high-energy, back-and-forth match in a loud, packed gym, both teams made outstanding plays, but Scarborough had a little too much for the top-ranked Capers (12-4).

But Cape didn’t go quietly. In the final set, it rallied from an early deficit and made it 20-20. It was 24-23 before the Red Storm clinched it.

Scarborough advanced 25-19, 21-25, 25-21, 25-23.

“We would have had to play a near perfect game to beat Scarborough,” said Cape Coach Sarah Boeckel. “And I don’t know if that would have been enough.”

Scarborough Coach Jon Roberts said his players were mentally prepared and loose.

“We came in with the attitude that we had nothing to lose,” he said. “We focused on the right mindset. We played aggressively. The team that usually wins these games is the one that comes out aggressively. Cape had the pressure. It’s tough being the defending champ.”

Cape appeared nervous at the start as Scarborough took an 8-3 lead in the opening set. Cape stayed close but never led. With the score 23-19, Scarborough took the last two points.

Finally settling down, Cape grabbed a 9-1 lead in the second set.

The Red Storm rallied to tie four times, the last at 19 before Tess Haller of the Capers had back-to-back kills.

In the third set, strong net play by Kacey Foerster and Taylor Marinko, and two perfectly placed back-to-back tips by Lilly Young that dropped for points provided the winning margin.

Emily Hanson was outstanding for Scarborough with her serves, digs and overall play. Equally outstanding for Cape was Maddie Bowe, who took charge at times with her kill shots.

“Maddie Bowe kept us in the game,” said Boeckel. “We dug ourselves too big of a hole.”

Hanson said this was the type of performance the Red Storm have been seeking.

“Ever since we started informal team workouts on July 5, this is the type of game we’ve been working for,” said Hanson.

“We had a slump midway in the season when we lost three games. We went to a tournament in Rhode Island before the playoffs and played well. That helped turn things around for us.”

Roberts said Hanson was the difference.

“We wouldn’t have won this without her play. Her serves and returns were outstanding,” he said.

Several players stepped up for Scarborough, with Marinko one of the leaders with her strong net play.

Scarborough and Cape Elizabeth split two games in the regular season.