When it rained, it poured Friday night for the Sanford High girls’ soccer team in a soggy Class A prelim against Portland at Fitzpatrick Stadium.

After 53 scoreless minutes, Julia Allen ended the drought with a goal for the 10th-seeded Spartans, and Megan O’Connell added another a minute later to give Sanford a 2-0 win over the seventh-ranked Bulldogs.

Sanford (9-5-1) will play at No. 2 Scarborough in the quarterfinals Wednesday. Portland ended its season at 7-4-4.

The Spartans not only won on the road but rectified a 3-0 loss to Portland a week ago.

“We certainly stepped it up in this game,” Coach Chris Coleman said. “We didn’t perform well in that game and they punished us. They walked away with a deserved win on their end.”

But it was Sanford that deserved to move on Friday, outshooting the Bulldogs, 15-9.

Portland goalkeeper Taylor Crosby finished with nine saves.Nikki Perez of Sanford recorded the shutout with seven.

“Today we played the best game that we’ve played all season for the entire 80 minutes,” Coleman said. “We were ready for tonight.”

While the halftime score didn’t reflect it, Sanford remained in control for most of the game. The Spartans created especially dangerous opportunities off their seven corner kicks, where – in the first half – they nearly converted two into header goals. Fortunately for the Bulldogs, one hit the goalpost while the other sailed over the crossbar.

Portland finished the half with four shots on goal – all of which were from deep.

Sanford defender Emma Graves attributed the Spartans’ success on defense to their communication.

“We just had really good practices – we stayed focused and set our minds on beating this team,” said Graves, a senior. “This could have been our last game.

“We knew we had to come out as the better team, and I think we did tonight.”

Sanford didn’t let up in the second half, nearly scoring on three corner kicks in the first three minutes.

The Bulldogs didn’t fire off a shot until 121/2 minutes in, when Kate Johnson launched a hard shot into Perez’s arms.

But Sanford snatched back momentum 20 seconds later, when Allen converted a Kristen O’Connell through ball into a goal with 27:06 left.

Crosby tried to make the sliding save, but Allen took advantage of the open net, tucking the ball into the right corner for a 1-0 lead.

With 24:48 remaining, Megan O’Connell finally converted on one of Sanford’s corner kicks with a header off Sydney Littlefield’s cross.

The Bulldogs nearly scored with 10 minutes remaining when Isabella More barely overshot a cross from Johnson. With seven minutes left, Annika More took another deep shot for Portland, but Perez made the save to keep the Bulldogs from closing the gap.

“It’s been an up and down season – one of highs and lows and close games as well,” Coleman said.

“We’ll be ready for Scarborough.”