MANCHESTER, N.H. — Three times the Portland Pirates staved off elimination.

They rallied in the third period to win the last game of the regular season.

They scored in the final seconds to break a tie in their first home playoff game.

They stunned Manchester in Game 4 to push the best team in the American Hockey League to a winner-take-all Game 5.

On Saturday night, they nearly outdid themselves.

After making up a three-goal deficit late in the second period, the eighth-seeded Pirates lost 5-3 to the No. 1 Manchester Monarchs before a crowd of 6,406 at Verizon Wireless Arena.

The Monarchs advance to the best-of-seven Eastern Conference semifinals against No. 4 Wilkes-Barre/Scranton, which swept No. 5 Syracuse in three games.

The other East semifinal pits No. 2 Hershey against No. 3 Hartford.

After the Pirates tied the score at 3 with half a second left in the second period – on a Brendan Shinnimin goal initially waved off by officials before a video review confirmed it – the Monarchs struck quickly in the third.

Michael Mersch scored his second of the game and Adrian Kempe added another 20 seconds later. Both goals came in the second minute of the period.

For the Pirates, Saturday’s loss marks the end of a four-year NHL affiliation with the Arizona Coyotes. In March, the Pirates signed a four-year deal with the Florida Panthers, who will bring in their own players and coaching staff.

Florida’s AHL affiliate this year was the San Antonio Rampage, the third seed in the Western Conference. San Antonio was swept out of the Western Conference playoffs Wednesday night by No. 6 Oklahoma City, losing two of the three games in overtime.

Arizona’s prospects and staff members will move to Springfield next season and become the Falcons, replacing Columbus, which shifted its affiliate to Cleveland to be closer to the parent club.

The biggest question heading into Game 5 was whether the Pirates could prevent Manchester from jumping out to another quick start. The home team had scored first in each game of the series and won every time.

On Saturday, the Monarchs again drew first blood in their own building. Mersch squeezed behind a pair of Pirates defenders to pounce on the rebound of a Sean Backman shot from the bottom of the right circle and flipped it past Pirates goaltender Louis Domingue before the game was two minutes old.

It wasn’t quite as quick as in Game 2 (20 seconds), but the early goal once more gave the Monarchs momentum and forced the Pirates to come from behind.

As Pirates Coach Ray Edwards said, “It’s hard to play that team when you’re chasing them, so the first 10 minutes is going to be real important.”

The Pirates trailed only 1-0 at the 10-minute mark, and Shinnimin, Tyler Gaudet and Christian Dvorak had decent chances at the equalizer, but Domingue’s continued difficulties with handling the puck – he had several gasp-inducing moments in Thursday’s 5-0 victory in Portland – cost Portland a demoralizing goal late in the period.

The goaltender ventured behind his net in an attempt at a clearing pass, but with Manchester’s Andrew Crescenzi bearing down on him, Domingue whiffed. Crescenzi gained control and centered quickly to Ryan Horvat, who shot into an unguarded net for a 2-0 lead.

It got worse for the Pirates. Just after AHL MVP Brian O’Neill rang a shot off the far post, Henrik Samuelsson drilled him into the boards near where Crescenzi drew a one-game suspension for boarding Darian Dziurzynski in Game 2. Like Crescenzi, Samuelsson was given a 5-minute major penalty, and Jordan Weal converted on the power play to make it 3-0 with 3:15 still to go on Manchester’s man-advantage.

The Pirates killed off the rest of the penalty and went on a power play of their own but managed only one shot, a weak backhand by a tightly guarded Jordan Szwarz.

With 9:52 remaining and elimination appearing more imminent, Edwards called time. He had done so in the second period Thursday night and the Pirates responded with a goal 20 seconds later.

On Saturday, they needed a little more than two minutes. A slashing penalty gave them another power-play opportunity, and Brandon Gormley patiently waited for Berube to commit before passing to Samuelsson in front for a goal that made it 3-1.

Two minutes later, Manchester took another penalty when O’Neill tumbled into Domingue behind the Portland net for goaltender interference. Gaudet and Szwarz worked a pretty give-and-go to make it 3-2 with 3:47 left.

Then came the improbable. Shinnimin, called for high-sticking with 2:10 left, scrambled out of the penalty box just as the Pirates were fending off another dangerous Manchester power play. He took a pass from Gaudet and took a buzzer-beating slap shot from the left circle that trickled through Berube.

Officials waved off the goal at first, but overturned it after reviewing the tape and put half a second on the clock.